Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 2a4c8e1e
authored
Jul 12, 2023
by
丁伟峰
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/develop' into develop
2 parents
c991694e
b78b3d3c
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
6 deletions
project-user/src/main/java/com/dituhui/pea/user/service/UserService.java
project-user/src/main/java/com/dituhui/pea/user/service/UserService.java
View file @
2a4c8e1
...
@@ -90,6 +90,15 @@ public class UserService {
...
@@ -90,6 +90,15 @@ public class UserService {
long
timestamp
=
System
.
currentTimeMillis
()
+
LIVE_TIME_MILLIS
;
long
timestamp
=
System
.
currentTimeMillis
()
+
LIVE_TIME_MILLIS
;
redisService
.
set
(
RedisKeyGroup
.
authToken
+
":"
+
uuid
,
user
,
timestamp
);
redisService
.
set
(
RedisKeyGroup
.
authToken
+
":"
+
uuid
,
user
,
timestamp
);
UserLoginDTO
userDTO
=
convertToUserLoginDTO
(
user
);
userDTO
.
setToken
(
uuid
);
return
Result
.
success
(
userDTO
);
}
else
{
return
Result
.
failed
(
"鉴权失败"
);
}
}
private
UserLoginDTO
convertToUserLoginDTO
(
UserEntity
user
)
{
UserLoginDTO
userDTO
=
BeanUtil
.
copyProperties
(
user
,
UserLoginDTO
.
class
);
UserLoginDTO
userDTO
=
BeanUtil
.
copyProperties
(
user
,
UserLoginDTO
.
class
);
// 获取角色
// 获取角色
List
<
UserRoleEntity
>
userRoles
=
userRoleDao
.
findByUserId
(
user
.
getId
());
List
<
UserRoleEntity
>
userRoles
=
userRoleDao
.
findByUserId
(
user
.
getId
());
...
@@ -102,6 +111,7 @@ public class UserService {
...
@@ -102,6 +111,7 @@ public class UserService {
// 获取资源
// 获取资源
List
<
RoleResourceEntity
>
roleResources
=
roleResourceDao
.
findByRoleIdIn
(
ids
);
List
<
RoleResourceEntity
>
roleResources
=
roleResourceDao
.
findByRoleIdIn
(
ids
);
log
.
info
(
"role size:{} roleResources:{}"
,
ids
.
size
(),
CollectionUtils
.
isNotEmpty
(
roleResources
));
if
(
CollectionUtils
.
isNotEmpty
(
roleResources
))
{
if
(
CollectionUtils
.
isNotEmpty
(
roleResources
))
{
List
<
String
>
resourceIds
=
roleResources
.
stream
().
map
(
r
->
r
.
getResourceId
())
List
<
String
>
resourceIds
=
roleResources
.
stream
().
map
(
r
->
r
.
getResourceId
())
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
...
@@ -111,16 +121,14 @@ public class UserService {
...
@@ -111,16 +121,14 @@ public class UserService {
}
}
}
}
userDTO
.
setToken
(
uuid
);
return
userDTO
;
return
Result
.
success
(
userDTO
);
}
else
{
return
Result
.
failed
(
"鉴权失败"
);
}
}
}
public
Result
<?>
getUserInfo
(
String
token
)
{
public
Result
<?>
getUserInfo
(
String
token
)
{
UserEntity
user
=
(
UserEntity
)
redisService
.
get
(
RedisKeyGroup
.
authToken
+
":"
+
token
);
UserEntity
user
=
(
UserEntity
)
redisService
.
get
(
RedisKeyGroup
.
authToken
+
":"
+
token
);
return
Result
.
success
(
user
);
UserLoginDTO
userDTO
=
convertToUserLoginDTO
(
user
);
userDTO
.
setToken
(
token
);
return
Result
.
success
(
userDTO
);
}
}
public
String
getUserName
(
String
userId
)
{
public
String
getUserName
(
String
userId
)
{
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment