|
@@ -3,6 +3,7 @@ package com.ruoyi.framework.aspectj;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.ruoyi.common.annotation.DataScope;
|
|
|
+import com.ruoyi.common.core.domain.BaseEntity;
|
|
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
@@ -145,7 +146,7 @@ public class DataScopeAspect
|
|
|
|
|
|
if (StrUtil.isNotBlank(sqlString.toString()))
|
|
|
{
|
|
|
- putDataScope(joinPoint, sqlString.substring(4));
|
|
|
+ putDataScope(joinPoint, "AND (" + sqlString.substring(4) + ")");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -181,12 +182,17 @@ public class DataScopeAspect
|
|
|
Object params = joinPoint.getArgs()[0];
|
|
|
if (Validator.isNotNull(params))
|
|
|
{
|
|
|
- try {
|
|
|
- Method getParams = params.getClass().getDeclaredMethod("getParams", null);
|
|
|
- Map<String, Object> invoke = (Map<String, Object>) getParams.invoke(params, null);
|
|
|
- invoke.put(DATA_SCOPE, sql);
|
|
|
- } catch (Exception e) {
|
|
|
- // 方法未找到 不处理
|
|
|
+ if(params instanceof BaseEntity) {
|
|
|
+ BaseEntity baseEntity = (BaseEntity) params;
|
|
|
+ baseEntity.getParams().put(DATA_SCOPE, "");
|
|
|
+ } else {
|
|
|
+ try {
|
|
|
+ Method getParams = params.getClass().getDeclaredMethod("getParams", null);
|
|
|
+ Map<String, Object> invoke = (Map<String, Object>) getParams.invoke(params, null);
|
|
|
+ invoke.put(DATA_SCOPE, sql);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 方法未找到 不处理
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|