| | |
| | | @Override |
| | | public void exportOperationsUser(XpOperationsUserQuery query, HttpServletResponse response) { |
| | | List<ExportOperationsUserVo> list = this.baseMapper.exportOperationsUser(query); |
| | | |
| | | // 查询角色名称 |
| | | List<Long> operationsUserIds = list.stream().map(ExportOperationsUserVo::getId).collect(Collectors.toList()); |
| | | |
| | | // 查询用户信息 |
| | | List<XpOperationsRole> xpOperationsRoles = xpOperationsRoleMapper.selectList(Wrappers.lambdaQuery(XpOperationsRole.class) |
| | | .in(XpOperationsRole::getOperationsUserId, operationsUserIds)); |
| | | |
| | | if(!CollectionUtils.isEmpty(xpOperationsRoles)){ |
| | | List<Long> roleIds = xpOperationsRoles.stream().map(XpOperationsRole::getRoleId).collect(Collectors.toList()); |
| | | // 查询列表关联的所有角色 |
| | | List<SysRole> sysRoles = sysRoleMapper.selectList(Wrappers.lambdaQuery(SysRole.class) |
| | | .in(SysRole::getId, roleIds)); |
| | | if(!CollectionUtils.isEmpty(sysRoles)){ |
| | | |
| | | // 角色匹配账号id |
| | | Map<Long, List<SysRole>> map = new HashMap<>(); |
| | | for (XpOperationsRole xpOperationsRole : xpOperationsRoles) { |
| | | List<SysRole> sysRoleList = sysRoles.stream().filter(sysRole -> sysRole.getId().equals(xpOperationsRole.getRoleId())).collect(Collectors.toList()); |
| | | map.put(xpOperationsRole.getOperationsUserId(), sysRoleList); |
| | | } |
| | | // 角色名称匹配 |
| | | for (ExportOperationsUserVo xpOperationsUserVO : list) { |
| | | List<SysRole> sysRoles1 = map.get(xpOperationsUserVO.getId()); |
| | | if(null != sysRoles1){ |
| | | xpOperationsUserVO.setRoleName(sysRoles1.stream().map(SysRole::getRoleName).collect(Collectors.joining(";"))); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | ExcelUtil<ExportOperationsUserVo> util = new ExcelUtil<ExportOperationsUserVo>(ExportOperationsUserVo.class); |
| | | util.exportExcel(response, list, "运维人员管理列表"); |
| | | } |
| | |
| | | @Override |
| | | public void exportTemplate(HttpServletResponse response) { |
| | | ExcelUtil<ExportOperationsUserVo> util = new ExcelUtil<ExportOperationsUserVo>(ExportOperationsUserVo.class); |
| | | util.exportExcel(response); |
| | | util.importTemplateExcel(response, "运维人员管理列表"); |
| | | } |
| | | } |
| | |
| | | xou.nick_name, |
| | | xou.unique_number, |
| | | xou.avatar, |
| | | xou.`password`, |
| | | xou.PASSWORD, |
| | | xou.phone_number, |
| | | xou.remarks, |
| | | xou.`status`, |
| | | xou.STATUS, |
| | | xou.id_card_front, |
| | | xou.id_card_back, |
| | | xou.driver_license, |
| | |
| | | xou.is_deleted, |
| | | xou.create_time, |
| | | xou.update_time, |
| | | xou.create_by |
| | | xou.create_by, |
| | | bb.roleName |
| | | FROM |
| | | xp_operations_user xou |
| | | LEFT JOIN xp_operations_role a ON xou.id = a.operations_user_id |
| | | <where> |
| | | <if test="query.nickName != null and query.nickName != ''"> |
| | | and xou.nick_name like concat('%',#{query.nickName},'%') |
| | | </if> |
| | | <if test="query.phoneNumber != null and query.phoneNumber != ''"> |
| | | and xou.phone_number like concat('%',#{query.phoneNumber},'%') |
| | | </if> |
| | | <if test="query.roleId != null"> |
| | | and xor.role_id = #{query.roleId} |
| | | </if> |
| | | <if test="query.status != null"> |
| | | and xou.status = #{query.status} |
| | | </if> |
| | | AND xou.is_deleted = 0 |
| | | </where> |
| | | left join ( |
| | | select a.operations_user_id, GROUP_CONCAT(b.role_name SEPARATOR ';') as roleName from xp_operations_role a |
| | | left join sys_role b on (a.role_id = b.id) |
| | | group by a.operations_user_id |
| | | ) bb on (xou.id = bb.operations_user_id) |
| | | WHERE xou.is_deleted = 0 |
| | | <if test="query.nickName != null and query.nickName != ''"> |
| | | and xou.nick_name like concat('%',#{query.nickName},'%') |
| | | </if> |
| | | <if test="query.phoneNumber != null and query.phoneNumber != ''"> |
| | | and xou.phone_number like concat('%',#{query.phoneNumber},'%') |
| | | </if> |
| | | <if test="query.roleId != null"> |
| | | AND EXISTS (SELECT 1 FROM xp_operations_role xore |
| | | WHERE xore.operations_user_id = xou.id |
| | | AND xore.role_id = #{query.roleId}) |
| | | </if> |
| | | <if test="query.status != null"> |
| | | and xou.status = #{query.status} |
| | | </if> |
| | | order by xou.create_time desc |
| | | </select> |
| | | </mapper> |