mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2026-08-26 13:27:14 +00:00
fix 修复 数据权限对union语句不兼容问题
This commit is contained in:
+7
-2
@@ -26,14 +26,19 @@ public class DataPermissionAdvice implements MethodInterceptor {
|
||||
public Object invoke(MethodInvocation invocation) throws Throwable {
|
||||
Object target = invocation.getThis();
|
||||
Method method = invocation.getMethod();
|
||||
DataPermission previousPermission = DataPermissionHelper.getPermission();
|
||||
// 设置权限注解
|
||||
DataPermissionHelper.setPermission(getDataPermissionAnnotation(target, method));
|
||||
try {
|
||||
// 执行代理方法
|
||||
return invocation.proceed();
|
||||
} finally {
|
||||
// 清除权限注解
|
||||
DataPermissionHelper.removePermission();
|
||||
// 恢复上一层权限上下文,兼容嵌套 Mapper 调用
|
||||
if (previousPermission == null) {
|
||||
DataPermissionHelper.removePermission();
|
||||
} else {
|
||||
DataPermissionHelper.setPermission(previousPermission);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-3
@@ -71,13 +71,17 @@ public class PlusDataPermissionHandler {
|
||||
*/
|
||||
public Expression getSqlSegment(Expression where, boolean isSelect) {
|
||||
try {
|
||||
DataPermission dataPermission = getDataPermission();
|
||||
if (dataPermission == null) {
|
||||
throw new ServiceException("数据权限上下文缺失,请检查 @DataPermission 注解处理生命周期");
|
||||
}
|
||||
LoginUser currentUser = currentUser();
|
||||
// 如果是超级管理员或租户管理员,则不过滤数据
|
||||
if (LoginHelper.isSuperAdmin()) {
|
||||
return where;
|
||||
}
|
||||
// 构造数据过滤条件的 SQL 片段
|
||||
String dataFilterSql = buildDataFilter(getDataPermission(), currentUser, isSelect);
|
||||
String dataFilterSql = buildDataFilter(dataPermission, currentUser, isSelect);
|
||||
if (StringUtils.isBlank(dataFilterSql)) {
|
||||
return where;
|
||||
}
|
||||
@@ -91,8 +95,6 @@ public class PlusDataPermissionHandler {
|
||||
}
|
||||
} catch (JSQLParserException e) {
|
||||
throw new ServiceException("数据权限解析异常 => " + e.getMessage());
|
||||
} finally {
|
||||
DataPermissionHelper.removePermission();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user