Browse Source

token验证时间

sunhh 2 years ago
parent
commit
b5a6d14d08

+ 12 - 1
base-framework/src/main/java/com/ozs/framework/web/service/TokenService.java

@@ -10,6 +10,9 @@ import javax.servlet.http.HttpServletRequest;
 import com.ozs.common.core.domain.entity.SysDictData;
 import com.ozs.system.service.ISysDictTypeService;
 
+import lombok.extern.log4j.Log4j;
+import lombok.extern.log4j.Log4j2;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
@@ -33,6 +36,7 @@ import org.springframework.util.ObjectUtils;
  *
  * @author hx
  */
+@Log4j2
 @Component
 public class TokenService {
     // 令牌自定义标识
@@ -142,6 +146,8 @@ public class TokenService {
         redisCache.setCacheObject(loginUser.getUsername(), token1, tokens, TimeUnit.MINUTES);
         String userKey = getTokenKey(loginUser.getToken());
         redisCache.setCacheObject(userKey, loginUser, tokens, TimeUnit.MINUTES);
+        log.info("token1-----" + token1);
+        log.info("loginUser-----" + loginUser.toString());
         return token1;
     }
 
@@ -196,8 +202,13 @@ public class TokenService {
         } else {
             tokens = expireTime;
         }
-//        redisCache.setCacheObject(loginUser.getUsername(), loginUser.getToken(), tokens, TimeUnit.MINUTES);
+        Map<String, Object> claims = new HashMap<>();
+        claims.put(Constants.LOGIN_USER_KEY, loginUser.getToken());
+        String token1 = createToken(claims);
+        redisCache.setCacheObject(loginUser.getUsername(), token1, tokens, TimeUnit.MINUTES);
         redisCache.setCacheObject(userKey, loginUser, tokens, TimeUnit.MINUTES);
+        log.info("token12-----" + token1);
+        log.info("loginUser2-----" + loginUser.toString());
     }
 
     /**