|
|
@@ -2,6 +2,8 @@ package com.dk.common.infrastructure.util;
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.dk.common.util.oauth.AESSecurityUtil;
|
|
|
+import com.dk.common.util.oauth.JwtUtil;
|
|
|
import com.google.common.base.CaseFormat;
|
|
|
import org.apache.ibatis.builder.StaticSqlSource;
|
|
|
import org.apache.ibatis.executor.Executor;
|
|
|
@@ -15,8 +17,11 @@ import org.apache.ibatis.scripting.defaults.DefaultParameterHandler;
|
|
|
import org.apache.ibatis.scripting.defaults.RawSqlSource;
|
|
|
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.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.beans.BeanInfo;
|
|
|
import java.beans.Introspector;
|
|
|
import java.beans.PropertyDescriptor;
|
|
|
@@ -41,11 +46,33 @@ import java.util.Map;
|
|
|
public class MybatisSqlIntercept implements Interceptor {
|
|
|
|
|
|
public static String I18N = "";
|
|
|
- public static Integer cpId = 0;
|
|
|
// public static String primaryKey = null;
|
|
|
|
|
|
+ @Value("${aes-key}")
|
|
|
+ private String AESKey;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private HttpServletRequest httpServletRequest;
|
|
|
+
|
|
|
@Override
|
|
|
public Object intercept(Invocation invocation) throws Throwable {
|
|
|
+
|
|
|
+ Integer cpId = 0;
|
|
|
+
|
|
|
+ String authorization = httpServletRequest.getHeader("Authorization");
|
|
|
+
|
|
|
+ if(authorization != null) {
|
|
|
+
|
|
|
+ String[] tokens = authorization.split(" ");
|
|
|
+ String decrypt = AESSecurityUtil.decrypt(AESKey, tokens[1]);
|
|
|
+ String cpIdString = JwtUtil.getCpId(decrypt);
|
|
|
+ if (cpIdString != null) {
|
|
|
+ //设置企业Id
|
|
|
+ cpId = Integer.valueOf(cpIdString);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
Object[] args = invocation.getArgs();
|
|
|
Object[] args2 = new Object[4];
|
|
|
args2[3] = args[3];
|