Source/plt-web/plt-web-parent/plt-web-api/src/main/java/com/vci/pagemodel/PLTabButtonVO.java
@@ -76,7 +76,7 @@ private List<PLTabButtonVO> children; /** * æ¯å¦æ¾ç¤º * æ¾ç¤ºæ¹å¼ */ private String displayMode; @@ -91,7 +91,7 @@ private String authorization; /** * æ¾ç¤ºæ¹å¼ * æ¯å¦æ¾ç¤º */ private String show; Source/plt-web/plt-web-parent/plt-web-base/pom.xml
@@ -73,6 +73,23 @@ <artifactId>icegridgui</artifactId> <version>1.0.RELEASE</version> </dependency> <!--redis start--> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId> <version>2.1.5.RELEASE</version> </dependency> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.9.0</version> </dependency> <!--redis end--> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.13.3</version> </dependency> </dependencies> </project> Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/constant/VConstant.java
@@ -82,6 +82,11 @@ public static final String SYS_ENUM_KEY = "sys_enum:"; /** * å½åç»å½çç¨æ·æ»æ°cache key */ public static final String CURRENT_LOGGED_USERS_KEY = "current_logged_users"; /** * èµæºæ å°è·¯å¾ åç¼ */ public static final String RESOURCE_PREFIX = "/profile"; Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/interceptor/VciLogAfterInterceptor.java
@@ -1,8 +1,6 @@ package com.vci.starter.web.interceptor; import com.vci.starter.web.constant.TokenKeyConstant; import com.vci.starter.web.util.VciBaseUtil; import com.vci.starter.web.util.WebThreadLocalUtil; import org.apache.commons.lang3.StringUtils; import org.slf4j.MDC; import org.springframework.beans.factory.annotation.Autowired; Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/interceptor/VciSecurityInterceptor.java
@@ -4,9 +4,11 @@ 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; @@ -15,15 +17,11 @@ 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; @@ -56,6 +54,9 @@ @Autowired private VciSessionForLoginI vciSessionForLoginI; @Autowired private RedisService redisService; /** * æ§è¡æ¦æª * @param request 请æ±å¯¹è±¡ @@ -76,7 +77,7 @@ if(StringUtils.isBlank(userToken)){ userToken = request.getParameter(TokenKeyConstant.USER_TOKEN_KEY); } if(!(handler instanceof HandlerMethod)){ if(!(handler instanceof HandlerMethod)){ return true; } @@ -127,6 +128,11 @@ 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{ Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/redis/FastJson2JsonRedisSerializer.java
ÎļþÃû´Ó Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/redis/FastJson2JsonRedisSerializer.java ÐÞ¸Ä @@ -1,4 +1,4 @@ package com.vci.web.redis; package com.vci.starter.web.redis; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.serializer.SerializerFeature; Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/redis/RedisConfig.java
ÎļþÃû´Ó Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/redis/RedisConfig.java ÐÞ¸Ä @@ -1,4 +1,4 @@ package com.vci.web.redis; package com.vci.starter.web.redis; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.cache.annotation.CachingConfigurerSupport; Source/plt-web/plt-web-parent/plt-web-base/src/main/java/com/vci/starter/web/redis/RedisService.java
ÎļþÃû´Ó Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/redis/RedisService.java ÐÞ¸Ä @@ -1,4 +1,4 @@ package com.vci.web.redis; package com.vci.starter.web.redis; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -11,6 +11,7 @@ import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; import java.io.IOException; import java.util.*; @@ -21,10 +22,9 @@ * @author dangsn **/ @SuppressWarnings(value = { "unchecked", "rawtypes" }) @Component @Service @Slf4j public class RedisService { public class RedisService { @Autowired(required = false) public RedisTemplate redisTemplate; @@ -393,19 +393,33 @@ /** * ç¨æ·ç»å½ * @param currentLoggedUserKey * @param username */ public void userLogin(String currentLoggedUserKey,String username) { redisTemplate.opsForSet().add(currentLoggedUserKey, username); public void increOnlineUser(String currentLoggedUserKey) { // æ£æ¥é®æ¯å¦åå¨ if (!redisTemplate.hasKey(currentLoggedUserKey)) { // 妿é®ä¸åå¨ï¼åå§å为0 redisTemplate.opsForValue().set(currentLoggedUserKey, 0); } // èªå¢å¨çº¿ç¨æ·æ° redisTemplate.opsForValue().increment(currentLoggedUserKey); } /** * ç¨æ·ç»åº * @param currentLoggedUserKey * @param username */ public void userLogout(String currentLoggedUserKey,String username) { redisTemplate.opsForSet().remove(currentLoggedUserKey, username); public void decreOnlineUser(String currentLoggedUserKey) { // æ£æ¥å½åå¨çº¿ç¨æ·æ° String currentLoggedUser = (String)redisTemplate.opsForValue().get(currentLoggedUserKey); if (currentLoggedUser != null) { Long currentCount = Long.parseLong((String)redisTemplate.opsForValue().get(currentLoggedUserKey)); if(currentCount > 0){ } // èªåå¨çº¿ç¨æ·æ° redisTemplate.opsForValue().decrement(currentLoggedUserKey); } } /** @@ -413,8 +427,8 @@ * @param currentLoggedUserKey * @return */ public long getCurrentLoggedUserCount(String currentLoggedUserKey) { return redisTemplate.opsForSet().size(currentLoggedUserKey); public long getCurrentOnlineUserCount(String currentLoggedUserKey) { return Long.parseLong(redisTemplate.opsForValue().get(currentLoggedUserKey).toString()); } /** Source/plt-web/plt-web-parent/plt-web/pom.xml
@@ -106,23 +106,6 @@ <version>0.9.11</version> </dependency> <!--redis start--> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-redis</artifactId> <version>2.1.5.RELEASE</version> </dependency> <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</artifactId> <version>2.9.0</version> </dependency> <!--redis end--> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.13.3</version> </dependency> </dependencies> <build> Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmHMSysModConfigServiceImpl.java
@@ -12,13 +12,14 @@ import com.vci.starter.poi.bo.WriteExcelData; import com.vci.starter.poi.bo.WriteExcelOption; import com.vci.starter.poi.util.ExcelUtil; import com.vci.starter.web.constant.VConstant; import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.pagemodel.BaseResult; import com.vci.starter.web.pagemodel.SessionInfo; import com.vci.starter.web.util.LocalFileUtil; import com.vci.starter.web.util.VciBaseUtil; import com.vci.starter.web.util.WebThreadLocalUtil; import com.vci.web.redis.RedisService; import com.vci.starter.web.redis.RedisService; import com.vci.web.util.Func; import com.vci.web.util.PlatformClientUtil; import org.slf4j.Logger; @@ -62,11 +63,6 @@ @Autowired private RedisService redisService; /** * å½åç»å½çç¨æ·æ»æ°key */ private static final String CURRENT_LOGGED_USERS_KEY = "current_logged_users"; /** * æ¥å¿ @@ -609,8 +605,6 @@ return res; } /** * æ£æ¥æ¯å¦åå¨å¼ç¨å ³ç³» * @param ids @@ -795,7 +789,7 @@ */ @Override public long getOnlineUsersNum() { long currentLoggedUserCount = redisService.getCurrentLoggedUserCount(CURRENT_LOGGED_USERS_KEY); long currentLoggedUserCount = redisService.getCurrentOnlineUserCount(VConstant.CURRENT_LOGGED_USERS_KEY); return currentLoggedUserCount; } Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/frameworkcore/compatibility/impl/SmSessionForLoginImpl.java
@@ -13,7 +13,7 @@ import com.vci.starter.web.util.*; import com.vci.constant.CacheNameConstant; import com.vci.web.properties.WebProperties; import com.vci.web.redis.RedisService; import com.vci.starter.web.redis.RedisService; import com.vci.web.service.WebBoServiceI; import com.vci.web.util.PlatformClientUtil; import com.vci.web.util.WebUtil; Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/LoginServiceImpl.java
@@ -19,6 +19,7 @@ import com.vci.starter.web.annotation.bus.VciLoginAfter; import com.vci.starter.web.annotation.bus.VciLogoutBefore; import com.vci.starter.web.annotation.bus.VciLogoutPlugin; import com.vci.starter.web.constant.VConstant; import com.vci.starter.web.exception.VciBaseException; import com.vci.starter.web.interceptor.VciSessionForLoginI; import com.vci.starter.web.pagemodel.RequestClientInfo; @@ -30,7 +31,7 @@ import com.vci.constant.CacheNameConstant; import com.vci.dto.LoginUserDTO; import com.vci.web.properties.WebProperties; import com.vci.web.redis.RedisService; import com.vci.starter.web.redis.RedisService; import com.vci.web.service.LoginServiceI; import com.vci.web.util.Func; import com.vci.web.util.PlatformClientUtil; @@ -128,11 +129,6 @@ private PlatformClientUtil platformClientUtil; /** * å½åç»å½çç¨æ·æ»æ°key */ private static final String CURRENT_LOGGED_USERS_KEY = "current_logged_users"; /** * æ§è¡ç»å½ * @param userDTO ç»å½ä¿¡æ¯ * @param clientInfo 请æ±ç客æ·ç«¯çä¿¡æ¯ @@ -151,7 +147,7 @@ * @return æ§è¡ç»æ * @throws VciBaseException åæ°é误ï¼ç¨æ·ä¸è½ç»å½ç伿åºå¼å¸¸ */ private LoginResultBO login(LoginUserDTO userDTO, RequestClientInfo clientInfo, boolean checkPassword/*åç¹ç»å½ä¸éè¦æ ¡éªå¯ç */) throws VciBaseException, PLException { private LoginResultBO login(LoginUserDTO userDTO, RequestClientInfo clientInfo, boolean checkPassword/*åç¹ç»å½ä¸éè¦æ ¡éªå¯ç */) throws VciBaseException { LoginResultBO loginResult = new LoginResultBO(); loginResult.setSuccess(false); @@ -172,7 +168,7 @@ String tokenKey = redisService.getCacheObject(userIdTokenKey); redisService.deleteObject(tokenKey); redisService.deleteObject(userIdTokenKey); redisService.userLogout(CURRENT_LOGGED_USERS_KEY,userDTO.getUserId()); redisService.decreOnlineUser(VConstant.CURRENT_LOGGED_USERS_KEY); } //3.è·åç¨æ·ç对象ï¼å¯¹è±¡ä¸å å«è§è²é¨é¨è¿æå¯ç çç¥ä¿¡æ¯(å½åç¨æ·æ²¡è®¾ç½®å¯ç çç¥å°±æ¯åçé»è®¤å¯ç çç¥)ï¼ @@ -249,7 +245,7 @@ //åå§åå¹³å°çtoken sessionForLogin.initInvocationInfo(sessionInfo); //è®°å½å½åç»å½äººæ°çæ»æ° redisService.userLogin(CURRENT_LOGGED_USERS_KEY,userDTO.getUserId()); redisService.increOnlineUser(VConstant.CURRENT_LOGGED_USERS_KEY); //æ·è´ç¨æ·å°æ°çsessionä¼è¯ä¸ copyUser2SessionInfo(user, sessionInfo, userDTO.getLangCode()); //æ·è´è¯·æ±ä¿¡æ¯å°sessionä¼è¯ä¸ @@ -567,7 +563,7 @@ }); } //æ¸ é¤åå½åç»å½çç¨æ·ï¼æ»æ°-1ï¼ redisService.userLogout(CURRENT_LOGGED_USERS_KEY,WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId()); redisService.decreOnlineUser(VConstant.CURRENT_LOGGED_USERS_KEY); sessionForLogin.logout(userToken); if(!CollectionUtils.isEmpty(logoutpluginBeanMap)){ logoutpluginBeanMap.forEach((k,v) -> { Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/UIManagerServiceImpl.java
@@ -21,7 +21,7 @@ import com.vci.starter.web.pagemodel.DataGrid; import com.vci.starter.web.pagemodel.SessionInfo; import com.vci.starter.web.util.*; import com.vci.web.redis.RedisService; import com.vci.starter.web.redis.RedisService; import com.vci.web.service.OsBtmServiceI; import com.vci.web.service.UIManagerServiceI; import com.vci.web.util.*;