组织机构权限

This commit is contained in:
liux 2026-01-05 12:14:08 +08:00
parent 0902ca2bef
commit 22cbc8ec7d
2 changed files with 19 additions and 5 deletions

View File

@ -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);
}

View File

@ -75,7 +75,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectDeptVo"/>
where d.del_flag = '0'
<if test="companyId != null and companyId != 0">
AND (find_in_set(#{companyId}, ancestors) or dept_id = #{companyId})
<!-- 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)
)
</if>
<if test="deptId != null and deptId != 0">
AND dept_id = #{deptId}