소스 검색

获取token

trick9191 7 년 전
부모
커밋
16b223a158
1개의 변경된 파일18개의 추가작업 그리고 3개의 파일을 삭제
  1. 18 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SystemDataRedis.java

+ 18 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SystemDataRedis.java

@ -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;
    }
    /**