【8.1.1】【db】【datasocpe】更新判空策略

pull/60/head
fengshuonan 2024-03-01 14:45:12 +08:00
parent 146971d55d
commit 7822dccbe4
1 changed files with 12 additions and 1 deletions

View File

@ -75,9 +75,20 @@ public class DataScopeAop implements Ordered {
DataScope datasource = currentMethod.getAnnotation(DataScope.class); DataScope datasource = currentMethod.getAnnotation(DataScope.class);
// 获取当前用户拥有的数据范围 // 获取当前用户拥有的数据范围
UserRoleDataScopeApi userRoleDataScopeApi = SpringUtil.getBean(UserRoleDataScopeApi.class); UserRoleDataScopeApi userRoleDataScopeApi = null;
try {
userRoleDataScopeApi = SpringUtil.getBean(UserRoleDataScopeApi.class);
} catch (Exception e) {
log.error("无法找到用户权限获取的类!", e);
return point.proceed();
}
DataScopeConfig userRoleDataScopeConfig = userRoleDataScopeApi.getUserRoleDataScopeConfig(); DataScopeConfig userRoleDataScopeConfig = userRoleDataScopeApi.getUserRoleDataScopeConfig();
// 获取不到用户的数据范围配置,也直接返回
if (userRoleDataScopeConfig == null) {
return point.proceed();
}
// 如果有单独配置特定的字段,以注解单独配置的字段为主 // 如果有单独配置特定的字段,以注解单独配置的字段为主
String userIdFieldName = datasource.userIdFieldName(); String userIdFieldName = datasource.userIdFieldName();
if (StrUtil.isNotBlank(userIdFieldName)) { if (StrUtil.isNotBlank(userIdFieldName)) {