com.wichell.core.util.TokenUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wichell-common Show documentation
Show all versions of wichell-common Show documentation
common project com.wichell.wichell jar
The newest version!
package com.wichell.core.util;
import com.wichell.core.Constants;
import com.wichell.core.support.Token;
import com.alibaba.fastjson.JSON;
public class TokenUtil {
public static void setTokenInfo(String token, String value) {
try {
Token tokenInfo = new Token();
tokenInfo.setTime(System.currentTimeMillis());
tokenInfo.setValue(value);
CacheUtil.getCache().hset(Constants.TOKEN_KEY, token, JSON.toJSONString(tokenInfo));
} catch (Exception e) {
throw new RuntimeException("保存token失败,错误信息:", e);
}
}
public static void delToken(String token) {
try {
CacheUtil.getCache().hdel(Constants.TOKEN_KEY, token);
} catch (Exception e) {
throw new RuntimeException("删除token失败,错误信息:", e);
}
}
public static Token getTokenInfo(String token) {
String value = (String) CacheUtil.getCache().hget(Constants.TOKEN_KEY, token);
Token tokenInfo = JSON.parseObject(value, Token.class);
return tokenInfo;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy