| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import cn.hutool.core.util.ObjectUtil; |
| | | import org.aspectj.lang.JoinPoint; |
| | | import org.aspectj.lang.annotation.Aspect; |
| | | import org.aspectj.lang.annotation.Before; |
| | |
| | | } |
| | | else if (DATA_SCOPE_DEPT.equals(dataScope)) |
| | | { |
| | | sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId())); |
| | | // sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId())); |
| | | if (ObjectUtil.isNotEmpty(user.getDeptIds())) |
| | | { |
| | | sqlString.append(StringUtils.format(" OR {}.dept_id IN ({}) ", deptAlias, StringUtils.join(user.getDeptIds(), ","))); |
| | | } |
| | | else |
| | | { |
| | | sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId())); |
| | | } |
| | | } |
| | | else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) |
| | | { |
| | | sqlString.append(StringUtils.format(" OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )", deptAlias, user.getDeptId(), user.getDeptId())); |
| | | Long[] deptIds = user.getDeptIds(); |
| | | if (deptIds != null && deptIds.length > 0) |
| | | { |
| | | // 多个部门时,查询这些部门及其所有子部门 |
| | | StringBuilder deptCondition = new StringBuilder(); |
| | | for (int i = 0; i < deptIds.length; i++) |
| | | { |
| | | if (i > 0) |
| | | { |
| | | deptCondition.append(" OR "); |
| | | } |
| | | deptCondition.append(StringUtils.format("{}.dept_id = {} OR find_in_set({}, {}.ancestors)", deptAlias, deptIds[i], deptIds[i], deptAlias)); |
| | | } |
| | | sqlString.append(StringUtils.format(" OR ( {} )", deptCondition.toString())); |
| | | } |
| | | //sqlString.append(StringUtils.format(" OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )", deptAlias, user.getDeptId(), user.getDeptId())); |
| | | } |
| | | else if (DATA_SCOPE_SELF.equals(dataScope)) |
| | | { |