From ebdacd7123e42c76cd7cb43938574cfeb0706250 Mon Sep 17 00:00:00 2001
From: lizijie <lzjiiie@163.com>
Date: Mon, 22 Mar 2021 09:11:36 +0800
Subject: [PATCH] 角色菜单配置

---
 screen-common/src/main/java/com/moral/util/TokenUtils.java |   37 ++++++++++++++++++++-----------------
 1 files changed, 20 insertions(+), 17 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 5c668f2..64e58d0 100644
--- a/screen-common/src/main/java/com/moral/util/TokenUtils.java
+++ b/screen-common/src/main/java/com/moral/util/TokenUtils.java
@@ -1,17 +1,16 @@
 package com.moral.util;
 
-import com.moral.constant.Constants;
+import com.moral.constant.ResponseCodeEnum;
 import com.moral.exception.TokenException;
-import com.sun.org.apache.bcel.internal.classfile.ConstantString;
+
 import lombok.extern.slf4j.Slf4j;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
 
 
-import java.util.HashMap;
-import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -24,7 +23,6 @@
 @Component
 @Slf4j
 public class TokenUtils {
-
     private static RedisTemplate redisTemplate;
 
     @Autowired
@@ -60,7 +58,8 @@
             return token;
         } catch (Exception e) {
             log.error("token���������������"+e.getMessage());
-            throw new TokenException(Constants.CODE_TOKEN_CREATE_ERROR,Constants.MSG_TOKEN_CREATE_ERROR);
+            throw new TokenException(ResponseCodeEnum.TOKEN_CREATE_ERROR.getCode(),
+                    ResponseCodeEnum.TOKEN_CREATE_ERROR.getMsg());
         }
     }
 
@@ -77,15 +76,18 @@
             String[] tokenArray = TokenEncryptUtils.decoded(token).split("/");
             //������token������������
             if (tokenArray.length != 2) {
-                throw new TokenException(Constants.CODE_TOKEN_ERROR,Constants.MSG_TOKEN_ERROR);
+                throw new TokenException(ResponseCodeEnum.TOKEN_INVALID.getCode(),
+                        ResponseCodeEnum.TOKEN_INVALID.getMsg());
             }
             //������token������������
             if (!redisTemplate.hasKey(token)) {
-                throw new TokenException(Constants.CODE_TOKEN_ERROR,Constants.MSG_TOKEN_ERROR);
+                throw new TokenException(ResponseCodeEnum.TOKEN_INVALID.getCode(),
+                        ResponseCodeEnum.TOKEN_INVALID.getMsg());
             }
         } catch (Exception e) {
             log.error("token���������������token������" + e.getMessage());
-            throw new TokenException(Constants.CODE_TOKEN_ERROR,Constants.MSG_TOKEN_ERROR);
+            throw new TokenException(ResponseCodeEnum.TOKEN_INVALID.getCode(),
+                    ResponseCodeEnum.TOKEN_INVALID.getMsg());
         }
     }
 
@@ -99,7 +101,8 @@
     public static Object getUserInfoByToken(String token) {
         Object userInfo = redisTemplate.opsForValue().get(token);
         if(userInfo==null)
-            throw new TokenException(Constants.CODE_TOKEN_ERROR,Constants.MSG_TOKEN_ERROR);
+            throw new TokenException(ResponseCodeEnum.TOKEN_INVALID.getCode(),
+                    ResponseCodeEnum.TOKEN_INVALID.getMsg());
         return userInfo;
     }
 
@@ -111,17 +114,17 @@
      * @Date: 2021/3/11
      */
     public static void destoryToken(String uid, String token) {
-        redisTemplate.delete("token");
+        redisTemplate.delete(token);
         redisTemplate.opsForHash().delete("user_token", uid);
     }
 
     /**
-    * @Description: token������
-            * @Param: [token]
-            * @return: void
-            * @Author: ���������
-            * @Date: 2021/3/11
-            */
+     * @Description: token������
+     * @Param: [token]
+     * @return: void
+     * @Author: ���������
+     * @Date: 2021/3/11
+     */
     public static void extendTokenTime(String token)  {
         redisTemplate.expire(token, validity_time, TimeUnit.SECONDS);
     }

--
Gitblit v1.8.0