Browse Source

update 优化新增用户与角色信息、用户与岗位信息逻辑

master
疯狂的狮子Li 2 years ago committed by Gitee
parent
commit
7475cff47d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
  1. 28
      ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

28
ruoyi-modules/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@ -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,7 +392,7 @@ 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.isNotNull(posts)) if (StringUtils.isNotEmpty(posts))
{ {
// 新增用户与岗位管理 // 新增用户与岗位管理
List<SysUserPost> list = new ArrayList<SysUserPost>(); List<SysUserPost> list = new ArrayList<SysUserPost>();
@ -419,12 +403,9 @@ 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,7 +415,7 @@ public class SysUserServiceImpl implements ISysUserService
*/ */
public void insertUserRole(Long userId, Long[] roleIds) public void insertUserRole(Long userId, Long[] roleIds)
{ {
if (StringUtils.isNotNull(roleIds)) if (StringUtils.isNotEmpty(roleIds))
{ {
// 新增用户与角色管理 // 新增用户与角色管理
List<SysUserRole> list = new ArrayList<SysUserRole>(); List<SysUserRole> list = new ArrayList<SysUserRole>();
@ -445,12 +426,9 @@ 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);
} }
} }
}
/** /**
* 通过用户ID删除用户 * 通过用户ID删除用户

Loading…
Cancel
Save