From 145e82ce09bd73bfe11afabd70a00f01a88d4be6 Mon Sep 17 00:00:00 2001
From: wangting <wangting@vci-tech.com>
Date: 星期三, 18 十二月 2024 17:37:00 +0800
Subject: [PATCH] 图标管理
---
Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/interceptor/VciSecurityInterceptor.java | 40 +++++++++++++++++++++++++++++++---------
1 files changed, 31 insertions(+), 9 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 1237741..68ef18a 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
@@ -4,9 +4,12 @@
import com.vci.starter.web.annotation.controller.VciUnCheckRight;
import com.vci.starter.web.autoconfigure.SpringMVCConfig;
import com.vci.starter.web.constant.TokenKeyConstant;
+import com.vci.starter.web.constant.VConstant;
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.redis.RedisService;
+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,6 +17,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
import org.springframework.util.CollectionUtils;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
@@ -30,6 +34,7 @@
* @author weidy
* @date 2019/11/7 2:32 PM
*/
+//@Configuration
public class VciSecurityInterceptor implements HandlerInterceptor {
/**
@@ -46,8 +51,11 @@
/**
* 浼氳瘽锛屾潈闄愶紝token鐨勬帴鍙�
*/
- @Autowired(required = false)
- private VciSessionForLoginI sessionForLoginI;
+ @Autowired
+ private VciSessionForLoginI vciSessionForLoginI;
+
+ @Autowired
+ private RedisService redisService;
/**
* 鎵ц鎷︽埅
@@ -69,7 +77,7 @@
if(StringUtils.isBlank(userToken)){
userToken = request.getParameter(TokenKeyConstant.USER_TOKEN_KEY);
}
- if(!(handler instanceof HandlerMethod)){
+ if(!(handler instanceof HandlerMethod)){
return true;
}
@@ -91,6 +99,11 @@
if(unCheckLogin){
//铏界劧涓嶆牎楠屾潈闄愶紝浣嗘槸濡傛灉token涓嶄负绌猴紝闇�瑕佹洿鏂板綋鍓嶇敤鎴�
SessionInfo sessionInfo = getSessionInfo(userToken);
+
+ if(sessionInfo != null){
+ //鍒濆鍖栧钩鍙扮殑token
+ vciSessionForLoginI.initInvocationInfo(sessionInfo);
+ }
return true;
}
@@ -115,11 +128,16 @@
if(logger.isErrorEnabled()) {
logger.error("token鍊奸潪娉曪紝鎴栬繃鏈燂紝鎴栬�呯敤鎴峰凡缁忚韪笅绾�," + userToken);
}
+ //鍒犻櫎缂撳瓨涓粺璁$殑鐢ㄦ埛淇℃伅
+ if(redisService == null){
+ redisService = ApplicationContextProvider.getBean(RedisService.class);
+ }
+ redisService.decreOnlineUser(VConstant.CURRENT_LOGGED_USERS_KEY);
sendErrorMsg(response,"token鍊奸潪娉曪紝鎴栬繃鏈燂紝鎴栬�呯敤鎴峰凡缁忚韪笅绾�," + userToken,1);
return false;
}else{
if(!unCheckUrls.contains(url)){
- if(sessionForLoginI == null){
+ if(vciSessionForLoginI == null){
//璇存槑娌″姙娉曟牎楠�
String msg = "璇锋眰璺緞"+ url +"娌℃潈闄愯闂�";
if(logger.isErrorEnabled()) {
@@ -129,11 +147,11 @@
return false;
}else{
//鍒濆鍖栧钩鍙扮殑token
- sessionForLoginI.initInvocationInfo(sessionInfo);
+ 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;
@@ -159,7 +177,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);
}
@@ -207,8 +229,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