From 4d5eff3b824dac8e50400b2ec1114cba4ed6a87c Mon Sep 17 00:00:00 2001
From: kaiyu <404897439@qq.com>
Date: Wed, 07 Apr 2021 17:05:43 +0800
Subject: [PATCH] screen-manage     完成sysarea模块查询     拦截器逻辑代码完成     修改organization和accountBug

---
 screen-common/src/main/java/com/moral/util/TokenUtils.java |   54 ++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 40 insertions(+), 14 deletions(-)

diff --git a/screen-common/src/main/java/com/moral/util/TokenUtils.java b/screen-common/src/main/java/com/moral/util/TokenUtils.java
index d1aa0aa..9bc1d5e 100644
--- a/screen-common/src/main/java/com/moral/util/TokenUtils.java
+++ b/screen-common/src/main/java/com/moral/util/TokenUtils.java
@@ -9,6 +9,7 @@
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
+import org.springframework.util.ObjectUtils;
 
 
 import java.util.concurrent.TimeUnit;
@@ -32,19 +33,20 @@
     }
 
     //token��������� ������������
-    private static final int validity_time = 60*30;
+    private static final int validity_time = 60 * 30;
 
     //������user_token���������������������token
-    public static boolean hHasKey(String uid){
-        return redisTemplate.opsForHash().hasKey("user_token",uid);
+    public static boolean hHasKey(String uid) {
+        return redisTemplate.opsForHash().hasKey("user_token", uid);
     }
 
     //������������id������token
-    public static Object hget(String uid){
-        return redisTemplate.opsForHash().get("user_token",uid);
+    public static Object hget(String uid) {
+        return redisTemplate.opsForHash().get("user_token", uid);
     }
+
     /**
-     * @Description: ������token,���������������������������������
+     * @Description: ������token, ���������������������������������
      * @Param: [uid] type��� ���������������manage  ���������������api
      * @return: java.lang.String
      * @Author: ���������
@@ -61,12 +63,12 @@
                 redisTemplate.delete(oldToken);
             //���token���������value���
             redisTemplate.opsForValue().set(token, userInfo);
-            redisTemplate.expire(token, validity_time, TimeUnit.SECONDS);
+            //redisTemplate.expire(token, validity_time, TimeUnit.SECONDS);
             //���token���������Hash���
             redisTemplate.opsForHash().put("user_token", uid, token);
             return token;
         } catch (Exception e) {
-            log.error("token���������������"+e.getMessage());
+            log.error("token���������������" + e.getMessage());
             throw new TokenException(ResponseCodeEnum.TOKEN_CREATE_ERROR.getCode(),
                     ResponseCodeEnum.TOKEN_CREATE_ERROR.getMsg());
         }
@@ -76,7 +78,7 @@
     /**
      * @Description: ������token
      * @Param: [type, token] type��� ���������������manage  ���������������api
-     * @return: java.util.Map<java.lang.String   ,   java.lang.Object>
+     * @return: java.util.Map<java.lang.String                               ,                               java.lang.Object>
      * @Author: ���������
      * @Date: 2021/3/10
      */
@@ -94,22 +96,22 @@
                         ResponseCodeEnum.TOKEN_INVALID.getMsg());
             }
         } catch (Exception e) {
-            log.error("token���������������token������" + e.getMessage());
             throw new TokenException(ResponseCodeEnum.TOKEN_INVALID.getCode(),
                     ResponseCodeEnum.TOKEN_INVALID.getMsg());
         }
     }
 
+
     /**
-     * @Description: ������token������������������  ������������
+     * @Description: ������token������������������
      * @Param: [token]
-     * @return: java.util.Map<java.lang.String   ,   java.lang.Object>
+     * @return: java.util.Map<java.lang.String                               ,                               java.lang.Object>
      * @Author: ���������
      * @Date: 2021/3/11
      */
     public static Object getUserInfoByToken(String token) {
         Object userInfo = redisTemplate.opsForValue().get(token);
-        if(userInfo==null)
+        if (userInfo == null)
             throw new TokenException(ResponseCodeEnum.TOKEN_INVALID.getCode(),
                     ResponseCodeEnum.TOKEN_INVALID.getMsg());
         return userInfo;
@@ -128,13 +130,37 @@
     }
 
     /**
+     * @Description: ������token
+     * @Param: [token]
+     * @return: void
+     * @Author: ���������
+     * @Date: 2021/4/1
+     */
+    public static void destoryToken(String token) {
+        destoryToken(getUidByToken(token), token);
+    }
+
+    /**
+     * @Description: ������TOKEN������Id
+     * @Param: [token]
+     * @return: void
+     * @Author: ���������
+     * @Date: 2021/4/1
+     */
+    public static String getUidByToken(String token) {
+        String[] string = TokenEncryptUtils.decoded(token).split("/");
+        return string[0];
+    }
+
+
+    /**
      * @Description: token������
      * @Param: [token]
      * @return: void
      * @Author: ���������
      * @Date: 2021/3/11
      */
-    public static void extendTokenTime(String token)  {
+    public static void extendTokenTime(String token) {
         redisTemplate.expire(token, validity_time, TimeUnit.SECONDS);
     }
 }

--
Gitblit v1.8.0