【修复】角色的数据范围为仅本人时,登陆后获取权限列表报错的问题

This commit is contained in:
YunaiV 2022-02-27 12:24:21 +08:00
parent a49b1431e5
commit c61811a622
2 changed files with 8 additions and 3 deletions

View File

@ -17,6 +17,7 @@ import lombok.extern.slf4j.Slf4j;
import net.sf.jsqlparser.expression.Alias;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.LongValue;
import net.sf.jsqlparser.expression.NullValue;
import net.sf.jsqlparser.expression.operators.conditional.OrExpression;
import net.sf.jsqlparser.expression.operators.relational.EqualsTo;
import net.sf.jsqlparser.expression.operators.relational.ExpressionList;
@ -110,10 +111,12 @@ public class DeptDataPermissionRule implements DataPermissionRule {
Expression deptExpression = this.buildDeptExpression(tableName,tableAlias, deptDataPermission.getDeptIds());
Expression userExpression = this.buildUserExpression(tableName, tableAlias, deptDataPermission.getSelf(), loginUser.getId());
if (deptExpression == null && userExpression == null) {
log.error("[getExpression][LoginUser({}) Table({}/{}) DeptDataPermission({}) 构建的条件为空]",
// TODO 芋艿获得不到条件的时候暂时不抛出异常而是不返回数据
log.warn("[getExpression][LoginUser({}) Table({}/{}) DeptDataPermission({}) 构建的条件为空]",
JsonUtils.toJsonString(loginUser), tableName, tableAlias, JsonUtils.toJsonString(deptDataPermission));
throw new NullPointerException(String.format("LoginUser(%d) Table(%s/%s) 构建的条件为空",
loginUser.getId(), tableName, tableAlias.getName()));
// throw new NullPointerException(String.format("LoginUser(%d) Table(%s/%s) 构建的条件为空",
// loginUser.getId(), tableName, tableAlias.getName()));
return new NullValue();
}
if (deptExpression == null) {
return userExpression;

View File

@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.auth.*;
import cn.iocoder.yudao.module.system.convert.auth.AuthConvert;
@ -63,6 +64,7 @@ public class AuthController {
@GetMapping("/get-permission-info")
@ApiOperation("获取登录用户的权限信息")
@DataPermission(enable = false) // 标记不使用数据权限避免SELF权限范围报错
public CommonResult<AuthPermissionInfoRespVO> getPermissionInfo() {
// 获得用户信息
AdminUserDO user = userService.getUser(getLoginUserId());