Commit 8817dce4 authored by chenzhao's avatar chenzhao

权限修改

parent 849fce4f
package com.yeejoin.amos.boot.module.hygf.api.config; package com.yeejoin.amos.boot.module.hygf.api.config;
import java.lang.annotation.ElementType; import java.lang.annotation.*;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD) @Target(ElementType.METHOD)
@Documented
public @interface DealerRestrict { public @interface DealerRestrict {
String[] field(); String[] field();
......
...@@ -13,14 +13,15 @@ import net.sf.jsqlparser.parser.CCJSqlParserUtil; ...@@ -13,14 +13,15 @@ import net.sf.jsqlparser.parser.CCJSqlParserUtil;
import net.sf.jsqlparser.statement.select.PlainSelect; import net.sf.jsqlparser.statement.select.PlainSelect;
import net.sf.jsqlparser.statement.select.Select; import net.sf.jsqlparser.statement.select.Select;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.executor.statement.StatementHandler; import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.mapping.BoundSql; import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement; import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.plugin.Interceptor; import org.apache.ibatis.plugin.*;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Plugin;
import org.apache.ibatis.reflection.MetaObject; import org.apache.ibatis.reflection.MetaObject;
import org.apache.ibatis.reflection.SystemMetaObject; import org.apache.ibatis.reflection.SystemMetaObject;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
...@@ -31,10 +32,12 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest; ...@@ -31,10 +32,12 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.util.*; import java.util.*;
import static com.alibaba.fastjson.JSON.parseArray; import static com.alibaba.fastjson.JSON.parseArray;
@Intercepts({@Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class,
RowBounds.class, ResultHandler.class}), @Signature(type = StatementHandler.class, method = "prepare", args = {Connection.class, Integer.class})})
public class DealerRestrictInterceptor implements Interceptor { public class DealerRestrictInterceptor implements Interceptor {
@Value("classpath:/json/DealerRestrict.json") @Value("classpath:/json/DealerRestrict.json")
...@@ -60,7 +63,7 @@ public class DealerRestrictInterceptor implements Interceptor { ...@@ -60,7 +63,7 @@ public class DealerRestrictInterceptor implements Interceptor {
//获取 参数之间关系 //获取 参数之间关系
String fileBetweenCondition = dealerRestrict.relationship(); String fileBetweenCondition = dealerRestrict.relationship();
//获取参数值, //获取参数值,
StdUserEmpower dataAuthRule = UserEmpowerThreadLocal.getDataAuthRule(); StdUserEmpower dataAuthRule =(StdUserEmpower) redisUtils.get("Emp_"+RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken()));
String[] data = new String[]{dataAuthRule.getDeveloperId().toString(),dataAuthRule.getRegionalCompaniesCode(),dataAuthRule.getUserId()}; String[] data = new String[]{dataAuthRule.getDeveloperId().toString(),dataAuthRule.getRegionalCompaniesCode(),dataAuthRule.getUserId()};
BoundSql boundSql = (BoundSql) metaObject.getValue("delegate.boundSql"); BoundSql boundSql = (BoundSql) metaObject.getValue("delegate.boundSql");
...@@ -155,7 +158,7 @@ public class DealerRestrictInterceptor implements Interceptor { ...@@ -155,7 +158,7 @@ public class DealerRestrictInterceptor implements Interceptor {
e.printStackTrace(); e.printStackTrace();
throw new BadRequest("权限认证失败!"); throw new BadRequest("权限认证失败!");
} finally { } finally {
UserEmpowerThreadLocal.clean();
} }
return invocation.proceed(); return invocation.proceed();
} }
......
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