Commit 6837cc9c authored by tianbo's avatar tianbo

权限拦截器修改

parent 0592f77d
...@@ -34,6 +34,8 @@ import org.apache.poi.ss.formula.functions.T; ...@@ -34,6 +34,8 @@ import org.apache.poi.ss.formula.functions.T;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
...@@ -63,7 +65,7 @@ public class PermissionInterceptor implements Interceptor { ...@@ -63,7 +65,7 @@ public class PermissionInterceptor implements Interceptor {
MetaObject metaObject = SystemMetaObject.forObject(statementHandler); MetaObject metaObject = SystemMetaObject.forObject(statementHandler);
MappedStatement mappedStatement = (MappedStatement) metaObject.getValue("delegate.mappedStatement"); MappedStatement mappedStatement = (MappedStatement) metaObject.getValue("delegate.mappedStatement");
// 处理mybatis plus // TODO 处理mybatis plus
String dataAuthRule = PermissionInterceptorContext.getDataAuthRule(); String dataAuthRule = PermissionInterceptorContext.getDataAuthRule();
// 被拦截方法 // 被拦截方法
...@@ -74,15 +76,15 @@ public class PermissionInterceptor implements Interceptor { ...@@ -74,15 +76,15 @@ public class PermissionInterceptor implements Interceptor {
PermissionInterceptorContext.clean(); PermissionInterceptorContext.clean();
return invocation.proceed(); return invocation.proceed();
} }
if(!ValidationUtil.isEmpty(dataAuth)){
dataAuthRule = !ValidationUtil.isEmpty(dataAuthRule) ? dataAuthRule : dataAuth.interfacePath();
}
// 数据权限地址为空返回空数据 // 数据权限地址为空返回空数据
if (ValidationUtil.isEmpty(dataAuth.interfacePath()) && ValidationUtil.isEmpty(dataAuthRule)) { if(ValidationUtil.isEmpty(dataAuthRule)){
// method.getReturnType().isPrimitive() = true 是count语句 // method.getReturnType().isPrimitive() = true 是count语句
PermissionInterceptorContext.clean(); PermissionInterceptorContext.clean();
return method.getReturnType().isPrimitive() ? invocation.proceed() : null; return method.getReturnType().isPrimitive() ? invocation.proceed() : null;
} }
dataAuthRule = ValidationUtil.isEmpty(dataAuth.interfacePath()) ? dataAuthRule : dataAuth.interfacePath();
ReginParams reginParam = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId() ReginParams reginParam = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId()
, RequestContext.getToken())).toString(), ReginParams.class); , RequestContext.getToken())).toString(), ReginParams.class);
if (ValidationUtil.isEmpty(reginParam) || ValidationUtil.isEmpty(reginParam.getUserModel())) { if (ValidationUtil.isEmpty(reginParam) || ValidationUtil.isEmpty(reginParam.getUserModel())) {
...@@ -361,4 +363,4 @@ public class PermissionInterceptor implements Interceptor { ...@@ -361,4 +363,4 @@ public class PermissionInterceptor implements Interceptor {
} }
return ruleValue; return ruleValue;
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment