From 328b0158c3d97f87efc7da22a1e3f5a7c258b127 Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期四, 04 七月 2024 19:17:17 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/interceptor/VciSecurityInterceptor.java |   33 ++++++++++++++++++++++++++-------
 1 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/interceptor/VciSecurityInterceptor.java b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/interceptor/VciSecurityInterceptor.java
index 932537b..9679f27 100644
--- a/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/interceptor/VciSecurityInterceptor.java
+++ b/Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/interceptor/VciSecurityInterceptor.java
@@ -7,6 +7,7 @@
 import com.vci.starter.web.enumpck.ResultCodeEnum;
 import com.vci.starter.web.pagemodel.BaseResult;
 import com.vci.starter.web.pagemodel.SessionInfo;
+import com.vci.starter.web.util.ApplicationContextProvider;
 import com.vci.starter.web.util.LangBaseUtil;
 import com.vci.starter.web.util.VciBaseUtil;
 import com.vci.starter.web.util.WebThreadLocalUtil;
@@ -14,10 +15,15 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.web.method.HandlerMethod;
 import org.springframework.web.servlet.HandlerInterceptor;
 
+import javax.annotation.Resource;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -30,6 +36,7 @@
  * @author weidy
  * @date 2019/11/7 2:32 PM
  */
+//@Configuration
 public class VciSecurityInterceptor implements HandlerInterceptor {
 
     /**
@@ -46,8 +53,8 @@
     /**
      * 浼氳瘽锛屾潈闄愶紝token鐨勬帴鍙�
      */
-    @Autowired(required = false)
-    private VciSessionForLoginI sessionForLoginI;
+    @Autowired
+    private VciSessionForLoginI vciSessionForLoginI;
 
     /**
      * 鎵ц鎷︽埅
@@ -92,6 +99,11 @@
             //铏界劧涓嶆牎楠屾潈闄愶紝浣嗘槸濡傛灉token涓嶄负绌猴紝闇�瑕佹洿鏂板綋鍓嶇敤鎴�
             SessionInfo sessionInfo = getSessionInfo(userToken);
 
+            if(sessionInfo != null){
+                //鍒濆鍖栧钩鍙扮殑token
+                vciSessionForLoginI.initInvocationInfo(sessionInfo);
+            }
+
             return true;
         }
         //鑾峰彇閰嶇疆鏂囦欢涓紝涓嶆牎楠屾潈闄愮殑璺緞
@@ -119,7 +131,7 @@
                 return false;
             }else{
                 if(!unCheckUrls.contains(url)){
-                    if(sessionForLoginI == null){
+                    if(vciSessionForLoginI == null){
                         //璇存槑娌″姙娉曟牎楠�
                         String msg = "璇锋眰璺緞"+ url +"娌℃潈闄愯闂�";
                         if(logger.isErrorEnabled()) {
@@ -128,9 +140,12 @@
                         sendErrorMsg(response,msg,2);
                         return false;
                     }else{
+                        //鍒濆鍖栧钩鍙扮殑token
+                        vciSessionForLoginI.initInvocationInfo(sessionInfo);
+
                         String systemPrivateToken = request.getHeader(TokenKeyConstant.SYSTEM_PRIVATE_KEY);
                         try {
-                            if (sessionForLoginI.checkRequestRights(request, systemPrivateToken, sessionInfo, handler)) {
+                            if (vciSessionForLoginI.checkRequestRights(request, systemPrivateToken, sessionInfo, handler)) {
                                 updateRequestTime(url,userToken);
                             }else{
                                 return false;
@@ -156,7 +171,11 @@
         SessionInfo sessionInfo = null;
         if(StringUtils.isNotBlank(userToken)){
             try{
-                sessionInfo = sessionForLoginI.getSessionInfoByToken(userToken);
+                if(vciSessionForLoginI == null){
+                    vciSessionForLoginI = ApplicationContextProvider.getBean(VciSessionForLoginI.class);
+                }
+
+                sessionInfo = vciSessionForLoginI.getSessionInfoByToken(userToken);
             }catch (Throwable e){
                 logger.error("鑾峰彇token鍑洪敊",e);
             }
@@ -204,8 +223,8 @@
         while(url1.startsWith("/")){
             url1 = url1.substring(1);
         }
-        if(sessionForLoginI != null && !unStorageRequestTimeUrls.contains(url1)){
-            sessionForLoginI.updateRequestTime(userToken);
+        if(vciSessionForLoginI != null && !unStorageRequestTimeUrls.contains(url1)){
+            vciSessionForLoginI.updateRequestTime(userToken);
         }
     }
 }

--
Gitblit v1.9.3