mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	!504 update 优化新增用户与角色信息、用户与岗位信息逻辑
Merge pull request !504 from 疯狂的狮子Li/N/A
This commit is contained in:
		@@ -381,23 +381,7 @@ public class SysUserServiceImpl implements ISysUserService
 | 
			
		||||
     */
 | 
			
		||||
    public void insertUserRole(SysUser user)
 | 
			
		||||
    {
 | 
			
		||||
        Long[] roles = 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);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        this.insertUserRole(user.getUserId, user.getRoleIds());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -408,10 +392,10 @@ public class SysUserServiceImpl implements ISysUserService
 | 
			
		||||
    public void insertUserPost(SysUser user)
 | 
			
		||||
    {
 | 
			
		||||
        Long[] posts = user.getPostIds();
 | 
			
		||||
        if (StringUtils.isNotNull(posts))
 | 
			
		||||
        if (StringUtils.isNotEmpty(posts))
 | 
			
		||||
        {
 | 
			
		||||
            // 新增用户与岗位管理
 | 
			
		||||
            List<SysUserPost> list = new ArrayList<SysUserPost>();
 | 
			
		||||
            List<SysUserPost> list = new ArrayList<SysUserPost>(posts.length);
 | 
			
		||||
            for (Long postId : posts)
 | 
			
		||||
            {
 | 
			
		||||
                SysUserPost up = new SysUserPost();
 | 
			
		||||
@@ -419,12 +403,9 @@ public class SysUserServiceImpl implements ISysUserService
 | 
			
		||||
                up.setPostId(postId);
 | 
			
		||||
                list.add(up);
 | 
			
		||||
            }
 | 
			
		||||
            if (list.size() > 0)
 | 
			
		||||
            {
 | 
			
		||||
            userPostMapper.batchUserPost(list);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 新增用户角色信息
 | 
			
		||||
@@ -434,10 +415,10 @@ public class SysUserServiceImpl implements ISysUserService
 | 
			
		||||
     */
 | 
			
		||||
    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>(roleIds.length);
 | 
			
		||||
            for (Long roleId : roleIds)
 | 
			
		||||
            {
 | 
			
		||||
                SysUserRole ur = new SysUserRole();
 | 
			
		||||
@@ -445,12 +426,9 @@ public class SysUserServiceImpl implements ISysUserService
 | 
			
		||||
                ur.setRoleId(roleId);
 | 
			
		||||
                list.add(ur);
 | 
			
		||||
            }
 | 
			
		||||
            if (list.size() > 0)
 | 
			
		||||
            {
 | 
			
		||||
            userRoleMapper.batchUserRole(list);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 通过用户ID删除用户
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user