From 64994bcb51726e8e26016b99e2de55278539b484 Mon Sep 17 00:00:00 2001
From: kaiyu <404897439@qq.com>
Date: Thu, 18 Mar 2021 11:33:24 +0800
Subject: [PATCH] api manage: 将全部用于判断isdelete的0/1替换为constants中的常量
---
screen-common/src/main/java/com/moral/util/TokenUtils.java | 32 +++++++++++++++++++-------------
1 files changed, 19 insertions(+), 13 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 7900fa2..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;
@@ -37,13 +38,13 @@
private static final int validity_time = 60*30;
/**
- * @Description: ������token
- * @Param: [type, uid] type��� ���������������manage ���������������api
+ * @Description: ������token,���������������������������������
+ * @Param: [uid] type��� ���������������manage ���������������api
* @return: java.lang.String
* @Author: ���������
* @Date: 2021/3/10
*/
- public static String getToken(String uid, Map<String, Object> userInfo) {
+ public static String getToken(String uid, Object userInfo) {
//������������token
try {
//������token
@@ -60,10 +61,11 @@
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());
}
-
}
+
/**
* @Description: ������token
@@ -77,29 +79,33 @@
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());
}
}
/**
- * @Description: ������token������������������
+ * @Description: ������token������������������ ������������
* @Param: [token]
* @return: java.util.Map<java.lang.String , java.lang.Object>
* @Author: ���������
* @Date: 2021/3/11
*/
- public static Map<String, Object> getUserInfoByToken(String token) {
- Map<String, Object> userInfo = (Map<String, Object>) redisTemplate.opsForValue().get(token);
+ 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,7 +117,7 @@
* @Date: 2021/3/11
*/
public static void destoryToken(String uid, String token) {
- redisTemplate.delete("token");
+ redisTemplate.delete(token);
redisTemplate.opsForHash().delete("user_token", uid);
}
--
Gitblit v1.8.0