Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
long-tern-care-service
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hubin
long-tern-care-service
Commits
250c782d
Commit
250c782d
authored
Apr 13, 2021
by
hubin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
用户管理
parent
5026ea26
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
2 deletions
+80
-2
GatewayConfig.java
...n/java/com/hungraim/ltc/gateway/config/GatewayConfig.java
+2
-2
UserController.java
...va/com/hungraim/ltc/system/controller/UserController.java
+78
-0
No files found.
gateway-service/src/main/java/com/hungraim/ltc/gateway/config/GatewayConfig.java
View file @
250c782d
...
@@ -18,12 +18,12 @@ public class GatewayConfig {
...
@@ -18,12 +18,12 @@ public class GatewayConfig {
public
static
String
NACOS_ROUTE_GROUP
;
public
static
String
NACOS_ROUTE_GROUP
;
@Value
(
"${spring.cloud.nacos.
discovery
.server-addr}"
)
@Value
(
"${spring.cloud.nacos.
config
.server-addr}"
)
public
void
setNacosServerAddr
(
String
nacosServerAddr
){
public
void
setNacosServerAddr
(
String
nacosServerAddr
){
NACOS_SERVER_ADDR
=
nacosServerAddr
;
NACOS_SERVER_ADDR
=
nacosServerAddr
;
}
}
@Value
(
"${spring.cloud.nacos.
discovery
.namespace}"
)
@Value
(
"${spring.cloud.nacos.
config
.namespace}"
)
public
void
setNacosNamespace
(
String
nacosNamespace
){
public
void
setNacosNamespace
(
String
nacosNamespace
){
NACOS_NAMESPACE
=
nacosNamespace
;
NACOS_NAMESPACE
=
nacosNamespace
;
}
}
...
...
system/system-admin-service/src/main/java/com/hungraim/ltc/system/controller/UserController.java
View file @
250c782d
...
@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -20,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -195,4 +196,81 @@ public class UserController {
...
@@ -195,4 +196,81 @@ public class UserController {
/**
* 新增用户
*/
@PostMapping
(
"/updateUser"
)
public
Result
updateUser
(
ReqUserInfo
reqUserInfo
)
{
if
(
reqUserInfo
.
getId
()
==
null
||
reqUserInfo
.
getId
()
==
0
)
{
return
Result
.
failed
(
"用户id无效!"
);
}
SystemUser
systemUser
=
userInfoService
.
getOne
(
new
LambdaQueryWrapper
<
SystemUser
>().
eq
(
SystemUser:
:
getUserId
,
reqUserInfo
.
getId
()));
if
(
systemUser
==
null
)
{
return
Result
.
failed
(
"用户id无效!"
);
}
boolean
flag
=
false
;
if
(!
reqUserInfo
.
getName
().
equals
(
systemUser
.
getRealName
()))
{
systemUser
.
setRealName
(
reqUserInfo
.
getName
());
flag
=
true
;
}
if
(!
reqUserInfo
.
getAccount
().
equals
(
systemUser
.
getAccount
()))
{
systemUser
.
setAccount
(
reqUserInfo
.
getAccount
());
flag
=
true
;
}
// if (!reqUserInfo.getAvatar().equals(systemUser.getAvatar())) {
// systemUser.setAvatar(reqUserInfo.getAvatar());
// flag = true;
// }
if
(!
reqUserInfo
.
getGender
().
equals
(
systemUser
.
getGender
()))
{
systemUser
.
setGender
(
reqUserInfo
.
getGender
());
flag
=
true
;
}
if
(!
reqUserInfo
.
getId
().
equals
(
systemUser
.
getUserId
()))
{
systemUser
.
setUserId
(
reqUserInfo
.
getId
());
flag
=
true
;
}
if
(
flag
)
{
systemUser
.
setUpdatedTime
(
new
Date
());
userInfoService
.
save
(
systemUser
);
}
//查询该角色下所有的资源数据
List
<
SystemUserRole
>
roleResources
=
userRoleService
.
list
(
new
LambdaQueryWrapper
<
SystemUserRole
>().
eq
(
SystemUserRole:
:
getUserId
,
reqUserInfo
.
getId
()));
if
(
reqUserInfo
.
getRoleIds
()==
null
){
reqUserInfo
.
setRoleIds
(
new
ArrayList
<>());
}
List
<
SystemUserRole
>
newRoleResources
=
reqUserInfo
.
getRoleIds
().
stream
()
.
filter
(
id
->
{
for
(
SystemUserRole
r
:
roleResources
)
{
if
(
r
.
getRoleId
().
equals
(
id
))
{
return
false
;
}
}
return
true
;
}).
map
(
resourceId
->
{
SystemUserRole
systemRoleResource
=
new
SystemUserRole
();
systemRoleResource
.
setRoleId
(
resourceId
);
systemRoleResource
.
setUserId
(
reqUserInfo
.
getId
());
return
systemRoleResource
;
}).
collect
(
Collectors
.
toList
());
userRoleService
.
saveBatch
(
newRoleResources
);
List
<
Long
>
deleteRoleResources
=
roleResources
.
stream
()
.
map
(
SystemUserRole:
:
getRoleId
).
filter
(
id
->
!
reqUserInfo
.
getRoleIds
().
contains
(
id
))
.
collect
(
Collectors
.
toList
());
userRoleService
.
removeByIds
(
deleteRoleResources
);
return
Result
.
success
(
"更新成功"
);
}
/**
* 根据id 删除用户
*/
@PostMapping
(
"/deleateByUserId"
)
public
Result
deleateByUserid
(
Long
id
){
this
.
userInfoService
.
removeById
(
id
);
return
Result
.
success
(
"更新成功"
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment