perf(core): 优化数据权限处理逻辑
- 合并判断条件,简化代码结构 - 提高超级管理员和未登录用户的处理效率
This commit is contained in:
@@ -33,16 +33,10 @@ public class MyDataPermissionHandler implements DataPermissionHandler {
|
|||||||
@Override
|
@Override
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public Expression getSqlSegment(Expression where, String mappedStatementId) {
|
public Expression getSqlSegment(Expression where, String mappedStatementId) {
|
||||||
// 如果是超级管理员,直接返回
|
// 如果是未登录,或者是定时任务执行的SQL,或者是超级管理员,直接返回
|
||||||
if(SecurityUtils.isRoot()){
|
if(SecurityUtils.getUserId() == null || SecurityUtils.isRoot()){
|
||||||
return where;
|
return where;
|
||||||
}
|
}
|
||||||
// 如果是未登录,或者是定时任务执行的SQL,直接返回
|
|
||||||
Long userId = SecurityUtils.getUserId();
|
|
||||||
if(userId == null){
|
|
||||||
return where;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取当前用户的数据权限
|
// 获取当前用户的数据权限
|
||||||
Integer dataScope = SecurityUtils.getDataScope();
|
Integer dataScope = SecurityUtils.getDataScope();
|
||||||
DataScopeEnum dataScopeEnum = IBaseEnum.getEnumByValue(dataScope, DataScopeEnum.class);
|
DataScopeEnum dataScopeEnum = IBaseEnum.getEnumByValue(dataScope, DataScopeEnum.class);
|
||||||
|
|||||||
Reference in New Issue
Block a user