mirror of
				https://github.com/dromara/RuoYi-Vue-Plus.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	add 添加按照部门id,角色id查询用户
This commit is contained in:
		@@ -66,4 +66,20 @@ public interface UserService {
 | 
			
		||||
     * @return 用户ids
 | 
			
		||||
     */
 | 
			
		||||
    List<Long> selectUserIdsByRoleIds(List<Long> roleIds);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 通过角色ID查询用户
 | 
			
		||||
     *
 | 
			
		||||
     * @param roleIds 角色ids
 | 
			
		||||
     * @return 用户
 | 
			
		||||
     */
 | 
			
		||||
    List<UserDTO> selectUsersByRoleIds(List<Long> roleIds);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 通过部门ID查询用户
 | 
			
		||||
     *
 | 
			
		||||
     * @param deptIds 部门ids
 | 
			
		||||
     * @return 用户
 | 
			
		||||
     */
 | 
			
		||||
    List<UserDTO> selectUsersByDeptIds(List<Long> deptIds);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -647,4 +647,26 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
 | 
			
		||||
        return StreamUtils.toList(userRoles, SysUserRole::getUserId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<UserDTO> selectUsersByRoleIds(List<Long> roleIds) {
 | 
			
		||||
        if (CollUtil.isEmpty(roleIds)) {
 | 
			
		||||
            return List.of();
 | 
			
		||||
        }
 | 
			
		||||
        List<SysUserRole> userRoles = userRoleMapper.selectList(
 | 
			
		||||
            new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getRoleId, roleIds));
 | 
			
		||||
        List<Long> userIds = StreamUtils.toList(userRoles, SysUserRole::getUserId);
 | 
			
		||||
        return selectListByIds(userIds);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public List<UserDTO> selectUsersByDeptIds(List<Long> deptIds) {
 | 
			
		||||
        if (CollUtil.isEmpty(deptIds)) {
 | 
			
		||||
            return List.of();
 | 
			
		||||
        }
 | 
			
		||||
        List<SysUserVo> list = baseMapper.selectVoList(new LambdaQueryWrapper<SysUser>()
 | 
			
		||||
            .select(SysUser::getUserId, SysUser::getUserName, SysUser::getNickName, SysUser::getEmail, SysUser::getPhonenumber)
 | 
			
		||||
            .eq(SysUser::getStatus, UserConstants.USER_NORMAL)
 | 
			
		||||
            .in(CollUtil.isNotEmpty(deptIds), SysUser::getDeptId, deptIds));
 | 
			
		||||
        return BeanUtil.copyToList(list, UserDTO.class);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user