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 97752fe..4455c9e 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 @@ -92,11 +92,17 @@ public class SysDeptServiceImpl implements ISysDeptService { Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId(); Long userId = SecurityUtils.getLoginUser().getUserid(); // 管理员和省公司可查看所有数据 - if (userId != null && deptId != null - && !userId.equals(ADMIN_ID) - && !deptId.equals(PROVINCE_COMPANY_DEPT_ID)) { - dept.setDeptId(deptId); +// if (userId != null && deptId != null +// && !userId.equals(ADMIN_ID) +// && !deptId.equals(PROVINCE_COMPANY_DEPT_ID)) { +// dept.setDeptId(deptId); +// } + if(ADMIN_ID.equals(userId)){ + dept.setCompanyId(1L); + }else{ + dept.setCompanyId(deptId); } + return deptMapper.selectDeptList(dept); } diff --git a/bonus-modules/bonus-system/src/main/resources/mapper/system/SysDeptMapper.xml b/bonus-modules/bonus-system/src/main/resources/mapper/system/SysDeptMapper.xml index 71e3bce..f260742 100644 --- a/bonus-modules/bonus-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/bonus-modules/bonus-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -75,7 +75,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where d.del_flag = '0' - AND (find_in_set(#{companyId}, ancestors) or dept_id = #{companyId}) + + and d.dept_id in + ( + select dept_id from sys_dept where dept_id = #{companyId} + union + select dept_id from sys_dept where parent_id = #{companyId} + union + select dept_id from sys_dept where find_in_set(#{companyId}, ancestors) + ) AND dept_id = #{deptId}