From 2c953876eab1622e2598a3d1ab92ae29e1d88fe5 Mon Sep 17 00:00:00 2001
From: kaiyu <404897439@qq.com>
Date: Thu, 18 Mar 2021 11:24:33 +0800
Subject: [PATCH] API项目:     更改全局异常处理器中的返回码常量 COMMON:     更改常量类和response枚举

---
 screen-common/src/main/java/com/moral/util/TokenUtils.java |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 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 389ebfd..cafd03b 100644
--- a/screen-common/src/main/java/com/moral/util/TokenUtils.java
+++ b/screen-common/src/main/java/com/moral/util/TokenUtils.java
@@ -1,6 +1,7 @@
 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;
@@ -60,7 +61,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 +79,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 +104,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;
     }
 

--
Gitblit v1.8.0