From 085df90e488067783759dcd63cdb5fb43a51ff1f Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期四, 26 九月 2024 12:44:04 +0800
Subject: [PATCH] 添加记录当前在线用户人数查询接口

---
 Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/LoginServiceImpl.java |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/LoginServiceImpl.java b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/LoginServiceImpl.java
index e860eee..eb454b7 100644
--- a/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/LoginServiceImpl.java
+++ b/Source/plt-web/plt-web-parent/plt-web/src/main/java/com/vci/web/service/impl/LoginServiceImpl.java
@@ -128,6 +128,11 @@
     private PlatformClientUtil platformClientUtil;
 
     /**
+     * 褰撳墠鐧诲綍鐨勭敤鎴锋�绘暟key
+     */
+    private static final String CURRENT_LOGGED_USERS_KEY = "current_logged_users";
+
+    /**
      * 鎵ц鐧诲綍
      * @param userDTO 鐧诲綍淇℃伅
      * @param clientInfo 璇锋眰鐨勫鎴风鐨勪俊鎭�
@@ -167,6 +172,7 @@
             String tokenKey = redisService.getCacheObject(userIdTokenKey);
             redisService.deleteObject(tokenKey);
             redisService.deleteObject(userIdTokenKey);
+            redisService.userLogout(CURRENT_LOGGED_USERS_KEY,userDTO.getUserId());
         }
 
         //3.鑾峰彇鐢ㄦ埛鐨勫璞★紙瀵硅薄涓寘鍚鑹查儴闂ㄨ繕鏈夊瘑鐮佺瓥鐣ヤ俊鎭�(褰撳墠鐢ㄦ埛娌¤缃瘑鐮佺瓥鐣ュ氨鏄彇鐨勯粯璁ゅ瘑鐮佺瓥鐣�)锛�
@@ -195,9 +201,8 @@
         machine.machine = clientInfo.getMachine();
         String token = null;
         try {
-            /*ThreeDES des = new ThreeDES();// 瀹炰緥鍖栦竴涓锟�?
-            des.getKey("daliantan0v0");// 鐢熸垚瀵嗗寵
-            String encPassword = des.getDesString(userDTO.getPassword());*/
+            //鍓嶇浼犺繃鏉ョ殑瀵嗙爜鏄粡杩囧姞瀵嗕紶杈撶殑锛屾墍浠ラ渶瑕佹寜鐓х害瀹氳В瀵嗭紝鍐嶄紶缁欏钩鍙拌繘琛屾瘮瀵�
+            userDTO.setPassword(Func.decryptAes(userDTO.getPassword(),"daliantan0v0vcip"));
             LoginResult chkRes = platformClientUtil.getFrameworkService().checkLogin(userDTO.getUserId(),userDTO.getPassword(), machine);
             loginResult.setFailCode(getErrorCode(chkRes));
             //loginResult.setFailMsgArray(new String[]{userDTO.getUserId(), String.valueOf(chkRes.auxInfo)});
@@ -243,6 +248,8 @@
         sessionInfo.setToken(token);
         //鍒濆鍖栧钩鍙扮殑token
         sessionForLogin.initInvocationInfo(sessionInfo);
+        //璁板綍褰撳墠鐧诲綍浜烘暟鐨勬�绘暟
+        redisService.userLogin(CURRENT_LOGGED_USERS_KEY,userDTO.getUserId());
         //鎷疯礉鐢ㄦ埛鍒版柊鐨剆ession浼氳瘽涓�
         copyUser2SessionInfo(user, sessionInfo, userDTO.getLangCode());
         //鎷疯礉璇锋眰淇℃伅鍒皊ession浼氳瘽涓�
@@ -559,6 +566,8 @@
                 }
             });
         }
+        //娓呴櫎瀛樺綋鍓嶇櫥褰曠殑鐢ㄦ埛锛堟�绘暟-1锛�
+        redisService.userLogout(CURRENT_LOGGED_USERS_KEY,WebThreadLocalUtil.getCurrentUserSessionInfoInThread().getUserId());
         sessionForLogin.logout(userToken);
         if(!CollectionUtils.isEmpty(logoutpluginBeanMap)){
             logoutpluginBeanMap.forEach((k,v) -> {

--
Gitblit v1.9.3