Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
RuoYi Vue
Commits
98fc3078
Unverified
Commit
98fc3078
authored
Jun 13, 2022
by
若依
Committed by
Gitee
Jun 13, 2022
Browse files
!504 update 优化新增用户与角色信息、用户与岗位信息逻辑
Merge pull request !504 from 疯狂的狮子Li/N/A
parents
b97a662f
a46c4bf0
Changes
1
Hide whitespace changes
Inline
Side-by-side
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
View file @
98fc3078
...
@@ -381,23 +381,7 @@ public class SysUserServiceImpl implements ISysUserService
...
@@ -381,23 +381,7 @@ public class SysUserServiceImpl implements ISysUserService
*/
*/
public
void
insertUserRole
(
SysUser
user
)
public
void
insertUserRole
(
SysUser
user
)
{
{
Long
[]
roles
=
user
.
getRoleIds
();
this
.
insertUserRole
(
user
.
getUserId
,
user
.
getRoleIds
());
if
(
StringUtils
.
isNotNull
(
roles
))
{
// 新增用户与角色管理
List
<
SysUserRole
>
list
=
new
ArrayList
<
SysUserRole
>();
for
(
Long
roleId
:
roles
)
{
SysUserRole
ur
=
new
SysUserRole
();
ur
.
setUserId
(
user
.
getUserId
());
ur
.
setRoleId
(
roleId
);
list
.
add
(
ur
);
}
if
(
list
.
size
()
>
0
)
{
userRoleMapper
.
batchUserRole
(
list
);
}
}
}
}
/**
/**
...
@@ -408,10 +392,10 @@ public class SysUserServiceImpl implements ISysUserService
...
@@ -408,10 +392,10 @@ public class SysUserServiceImpl implements ISysUserService
public
void
insertUserPost
(
SysUser
user
)
public
void
insertUserPost
(
SysUser
user
)
{
{
Long
[]
posts
=
user
.
getPostIds
();
Long
[]
posts
=
user
.
getPostIds
();
if
(
StringUtils
.
isNot
Null
(
posts
))
if
(
StringUtils
.
isNot
Empty
(
posts
))
{
{
// 新增用户与岗位管理
// 新增用户与岗位管理
List
<
SysUserPost
>
list
=
new
ArrayList
<
SysUserPost
>();
List
<
SysUserPost
>
list
=
new
ArrayList
<
SysUserPost
>(
posts
.
length
);
for
(
Long
postId
:
posts
)
for
(
Long
postId
:
posts
)
{
{
SysUserPost
up
=
new
SysUserPost
();
SysUserPost
up
=
new
SysUserPost
();
...
@@ -419,10 +403,7 @@ public class SysUserServiceImpl implements ISysUserService
...
@@ -419,10 +403,7 @@ public class SysUserServiceImpl implements ISysUserService
up
.
setPostId
(
postId
);
up
.
setPostId
(
postId
);
list
.
add
(
up
);
list
.
add
(
up
);
}
}
if
(
list
.
size
()
>
0
)
userPostMapper
.
batchUserPost
(
list
);
{
userPostMapper
.
batchUserPost
(
list
);
}
}
}
}
}
...
@@ -434,10 +415,10 @@ public class SysUserServiceImpl implements ISysUserService
...
@@ -434,10 +415,10 @@ public class SysUserServiceImpl implements ISysUserService
*/
*/
public
void
insertUserRole
(
Long
userId
,
Long
[]
roleIds
)
public
void
insertUserRole
(
Long
userId
,
Long
[]
roleIds
)
{
{
if
(
StringUtils
.
isNot
Null
(
roleIds
))
if
(
StringUtils
.
isNot
Empty
(
roleIds
))
{
{
// 新增用户与角色管理
// 新增用户与角色管理
List
<
SysUserRole
>
list
=
new
ArrayList
<
SysUserRole
>();
List
<
SysUserRole
>
list
=
new
ArrayList
<
SysUserRole
>(
roleIds
.
length
);
for
(
Long
roleId
:
roleIds
)
for
(
Long
roleId
:
roleIds
)
{
{
SysUserRole
ur
=
new
SysUserRole
();
SysUserRole
ur
=
new
SysUserRole
();
...
@@ -445,10 +426,7 @@ public class SysUserServiceImpl implements ISysUserService
...
@@ -445,10 +426,7 @@ public class SysUserServiceImpl implements ISysUserService
ur
.
setRoleId
(
roleId
);
ur
.
setRoleId
(
roleId
);
list
.
add
(
ur
);
list
.
add
(
ur
);
}
}
if
(
list
.
size
()
>
0
)
userRoleMapper
.
batchUserRole
(
list
);
{
userRoleMapper
.
batchUserRole
(
list
);
}
}
}
}
}
...
...
Write
Preview
Supports
Markdown
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