| | |
| | | {
|
| | | continue;
|
| | | }
|
| | | if (!StringUtils.containsAny(role.getPermissions(), Convert.toStrArray(permission)))
|
| | | // 无权限字符上下文(permission 为空,如员工删除这类无@PreAuthorize的接口)时,
|
| | | // 不做基于权限字符的预过滤,否则"全部数据"角色会在命中 DATA_SCOPE_ALL 前被 continue,
|
| | | // 最终落入"无任何角色匹配"的兜底,导致无法删除
|
| | | if (StringUtils.isNotBlank(permission) && !StringUtils.containsAny(role.getPermissions(), Convert.toStrArray(permission)))
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
| | | {
|
| | | sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId()));
|
| | | }
|
| | | else
|
| | | else if (StringUtils.isNotBlank(deptAlias))
|
| | | {
|
| | | // 数据权限为仅本人且没有userAlias别名不查询任何数据
|
| | | sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
|
| | | sqlString.append(StringUtils.format(" OR {}.dept_id = -1 ", deptAlias));
|
| | | }
|
| | | else
|
| | | {
|
| | | sqlString.append(" OR 1 = 0 ");
|
| | | }
|
| | | }
|
| | | conditions.add(dataScope);
|
| | |
| | | // 角色都不包含传递过来的权限字符,这个时候sqlString也会为空,所以要限制一下,不查询任何数据
|
| | | if (StringUtils.isEmpty(conditions))
|
| | | {
|
| | | sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
|
| | | if (StringUtils.isNotBlank(deptAlias))
|
| | | {
|
| | | sqlString.append(StringUtils.format(" OR {}.dept_id = -1 ", deptAlias));
|
| | | }
|
| | | else if (StringUtils.isNotBlank(userAlias))
|
| | | {
|
| | | sqlString.append(StringUtils.format(" OR {}.user_id = -1 ", userAlias));
|
| | | }
|
| | | else
|
| | | {
|
| | | sqlString.append(" OR 1 = 0 ");
|
| | | }
|
| | | }
|
| | |
|
| | | if (StringUtils.isNotBlank(sqlString.toString()))
|