From 5a7e5a0f595d3fbd54fd5847ae7cbe4e45e4fec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=B6=E4=B8=9C?= <1654135867@qq.com> Date: Sat, 29 Jun 2024 09:25:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SysUserServiceImpl.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java b/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java index eea44cf3..d05d4829 100644 --- a/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java +++ b/jeecg-boot-master/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/service/impl/SysUserServiceImpl.java @@ -141,7 +141,70 @@ public class SysUserServiceImpl extends ServiceImpl impl queryWrapper.ne("username", "_reserve_user_external"); Page page = new Page(pageNo, pageSize); IPage pageList = this.page(page, queryWrapper); + //批量查询用户的所属部门 + //step.1 先拿到全部的 useids + //step.2 通过 useids,一次性查询用户的所属部门名字 + List userIds = pageList.getRecords().stream().map(SysUser::getId).collect(Collectors.toList()); + if (userIds != null && userIds.size() > 0) { + Map useDepNames = this.getDepNamesByUserIds(userIds); + pageList.getRecords().forEach(item -> { + item.setOrgCodeTxt(useDepNames.get(item.getId())); + //查询用户的租户ids + List list = userTenantMapper.getTenantIdsByUserId(item.getId()); + if (oConvertUtils.isNotEmpty(list)) { + item.setRelTenantIds(StringUtils.join(list.toArray(), SymbolConstant.COMMA)); + } else { + item.setRelTenantIds(""); + } + }); + } + + result.setSuccess(true); + result.setResult(pageList); + //log.info(pageList.toString()); + return result; + } + + @Override + public Result> queryPageListzdzx(HttpServletRequest req, QueryWrapper queryWrapper, Integer pageSize, Integer pageNo) { + Result> result = new Result>(); + //update-begin-Author:wangshuai--Date:20211119--for:【vue3】通过部门id查询用户,通过code查询id + //部门ID + String departId = req.getParameter("departId"); + if (oConvertUtils.isNotEmpty(departId)) { + LambdaQueryWrapper query = new LambdaQueryWrapper<>(); + query.eq(SysUserDepart::getDepId, departId); + List list = sysUserDepartMapper.selectList(query); + List userIds = list.stream().map(SysUserDepart::getUserId).collect(Collectors.toList()); + //update-begin---author:wangshuai ---date:20220322 for:[issues/I4XTYB]查询用户时,当部门id 下没有分配用户时接口报错------------ + if (oConvertUtils.listIsNotEmpty(userIds)) { + queryWrapper.in("id", userIds); + } else { + return Result.OK(); + } + //update-end---author:wangshuai ---date:20220322 for:[issues/I4XTYB]查询用户时,当部门id 下没有分配用户时接口报错------------ + } + //用户ID + String code = req.getParameter("code"); + if (oConvertUtils.isNotEmpty(code)) { + queryWrapper.in("id", Arrays.asList(code.split(","))); + pageSize = code.split(",").length; + } + //update-end-Author:wangshuai--Date:20211119--for:【vue3】通过部门id查询用户,通过code查询id + //update-begin-author:taoyan--date:20220104--for: JTC-372 【用户冻结问题】 online授权、用户组件,选择用户都能看到被冻结的用户 + String status = req.getParameter("status"); + if (oConvertUtils.isNotEmpty(status)) { + queryWrapper.eq("status", Integer.parseInt(status)); + } + //update-end-author:taoyan--date:20220104--for: JTC-372 【用户冻结问题】 online授权、用户组件,选择用户都能看到被冻结的用户 + + //TODO 外部模拟登陆临时账号,列表不显示 + queryWrapper.ne("username", "_reserve_user_external"); + LoginUser user= (LoginUser)SecurityUtils.getSubject().getPrincipal(); + queryWrapper.eq("username",user.getUsername()); + Page page = new Page(pageNo, pageSize); + IPage pageList = this.page(page, queryWrapper); //批量查询用户的所属部门 //step.1 先拿到全部的 useids //step.2 通过 useids,一次性查询用户的所属部门名字