|
@ -2,6 +2,9 @@ package com.yihu.wlyy.util;
|
|
|
|
|
|
import com.yihu.wlyy.entity.security.Token;
|
|
|
import net.sf.json.JSONObject;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
@ -15,6 +18,8 @@ import java.util.Set;
|
|
|
@Component
|
|
|
public class SystemDataRedis {
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(SystemDataRedis.class);
|
|
|
|
|
|
@Autowired
|
|
|
private StringRedisTemplate redisTemplate;
|
|
|
|
|
@ -98,9 +103,19 @@ public class SystemDataRedis {
|
|
|
* @return
|
|
|
*/
|
|
|
public Token getToken(String tokenTypeName,String uid) {
|
|
|
String tokenJosn = redisTemplate.opsForValue().get("token:" + tokenTypeName + ":" + uid);
|
|
|
Token token = (Token)JSONObject.toBean(JSONObject.fromObject(tokenJosn),Token.class);
|
|
|
return token;
|
|
|
try{
|
|
|
//获取token
|
|
|
String tokenJosn = redisTemplate.opsForValue().get("token:" + tokenTypeName + ":" + uid);
|
|
|
if(StringUtils.isNotBlank(tokenJosn)){
|
|
|
Token token = (Token)JSONObject.toBean(JSONObject.fromObject(tokenJosn),Token.class);
|
|
|
return token;
|
|
|
}
|
|
|
return null;
|
|
|
}catch (Exception e){
|
|
|
logger.info("getToken:"+e.getMessage());
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/**
|