This commit is contained in:
2023-06-15 16:17:13 +08:00
parent a7ee9eadba
commit 076955a04f
20 changed files with 941 additions and 73 deletions

View File

@ -91,20 +91,20 @@ public class DataScopeAspect {
break;
} else if (DATA_SCOPE_CUSTOM.equals(dataScope)) {
sqlString.append(StrUtil.format(
" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias,
" OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = '{}' ) ", deptAlias,
role.getRoleId()));
} else if (DATA_SCOPE_DEPT.equals(dataScope)) {
sqlString.append(StrUtil.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId()));
sqlString.append(StrUtil.format(" OR {}.dept_id = '{}' ", deptAlias, user.getDeptId()));
} else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) {
sqlString.append(StrUtil.format(
" OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or {} )",
" OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = '{}' or {} )",
deptAlias, user.getDeptId(), DatabaseUtil.handleFindInSet(user.getDeptId(), "ancestors")));
} else if (DATA_SCOPE_SELF.equals(dataScope)) {
if (StrUtil.isNotBlank(userAlias)) {
sqlString.append(StrUtil.format(" OR {}.user_id = {} ", userAlias, user.getUserId()));
sqlString.append(StrUtil.format(" OR {}.user_id = '{}' ", userAlias, user.getUserId()));
} else {
// 数据权限为仅本人且没有userAlias别名不查询任何数据
sqlString.append(StrUtil.format(" OR {}.dept_id = 0 ", deptAlias));
sqlString.append(StrUtil.format(" OR {}.dept_id = '0' ", deptAlias));
}
}
conditions.add(dataScope);
@ -112,7 +112,7 @@ public class DataScopeAspect {
// 多角色情况下所有角色都不包含传递过来的权限字符这个时候sqlString也会为空所以要限制一下,不查询任何数据
if (CollUtil.isEmpty(conditions)) {
sqlString.append(StrUtil.format(" OR {}.dept_id = 0 ", deptAlias));
sqlString.append(StrUtil.format(" OR {}.dept_id = '0' ", deptAlias));
}
if (StrUtil.isNotBlank(sqlString)) {