From 48d410a8b71d8991c7c3bf598a0132c3f7dbdfeb Mon Sep 17 00:00:00 2001 From: weiweiw <14335254+weiweiw22@user.noreply.gitee.com> Date: Mon, 28 Oct 2024 11:29:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=89=8D=E4=B8=A4=E6=AC=A1?= =?UTF-8?q?=E7=9A=84=E6=8F=90=E4=BA=A4=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SysDeptServiceImpl.java | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/bonus-modules/bonus-system/src/main/java/com/bonus/system/service/impl/SysDeptServiceImpl.java b/bonus-modules/bonus-system/src/main/java/com/bonus/system/service/impl/SysDeptServiceImpl.java index e5b334e..6259463 100644 --- a/bonus-modules/bonus-system/src/main/java/com/bonus/system/service/impl/SysDeptServiceImpl.java +++ b/bonus-modules/bonus-system/src/main/java/com/bonus/system/service/impl/SysDeptServiceImpl.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.stream.Collectors; import com.bonus.common.core.web.domain.BaseEntity; +import com.bonus.system.mapper.SysUserMapper; import com.bonus.common.datascope.utils.CommonDataPermissionInfo; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -36,6 +37,9 @@ public class SysDeptServiceImpl implements ISysDeptService @Autowired private SysDeptMapper deptMapper; + @Autowired + private SysUserMapper userMapper; + @Autowired private SysRoleMapper roleMapper; @@ -71,6 +75,38 @@ public class SysDeptServiceImpl implements ISysDeptService return buildDeptTreeSelect(depts); } + /** + * 查询部门人员树结构信息 + * + * @param dept 部门信息 + * @return 部门树信息集合 + */ + @Override + public List selectDeptUserTreeList(SysDept dept) + { + if (dept != null && dept.getDeptId() != null && dept.getDeptId() == 0L) { + List userList = userMapper.getTree(dept); + return buildDeptTreeSelect(userList); + } + List depts = SpringUtils.getAopProxy(this).selectDeptList(dept); + for (SysDept sysDept : depts) { + SysUser paramUser = new SysUser(); + paramUser.setDeptId(sysDept.getDeptId()); + List users = userMapper.selectUserList(paramUser); + + List sysUsers = new ArrayList<>(); + for (SysUser user : users) { + SysUser userResult = userMapper.selectUserById(user.getUserId()); + user.setRoles(userResult.getRoles()); + if (user.getDeptId().equals(sysDept.getDeptId())) { + sysUsers.add(user); + } + } + sysDept.setSysUsers(sysUsers); + } + return buildDeptTreeSelect(depts); + } + /** * 构建前端所需要树结构 * @@ -228,7 +264,7 @@ public class SysDeptServiceImpl implements ISysDeptService if (dept.getParentId() == null){ dept.setParentId(0L); dept.setAncestors("0"); - } + } else { SysDept info = deptMapper.selectDeptById(dept.getParentId()); // 如果父节点不为正常状态,则不允许新增子节点 @@ -355,3 +391,4 @@ public class SysDeptServiceImpl implements ISysDeptService return getChildList(list, t).size() > 0 ? true : false; } } +