lyhzzz %!s(int64=3) %!d(string=hai) anos
pai
achega
3b6f82937a

+ 15 - 0
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/JwtUtil.java

@@ -118,9 +118,24 @@ public class JwtUtil {
             return null;
         }
     }
+    /**
+     * 获得token中的信息无需secret解密也能获得
+     *
+     * @return token中包含的用户名
+     */
+    public static String getLoginType(String token) {
+        try {
+            DecodedJWT jwt = JWT.decode(token);
+            return jwt.getClaim("loginType").asString();
+        } catch (JWTDecodeException e) {
+            return null;
+        }
+    }
 
     public static void main(String[] args) {
+        long start = System.currentTimeMillis();
         System.out.println(getUsername("eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMzExMjMxMTE3OCIsInVzZXJOYW1lIjoiMTMxMTIzMTExNzgiLCJpYXQiOjE1NjQwNDY0OTgsImp0aSI6IjhhZWJlNzhlLTU2OGUtNDY2Yi1iY2E3LWQ4ZjI0MjgxYzJhZCJ9.1N3UNjkT39mXtymfkJQVQJxOlFM3gfC6bgfur5mVmEU"));
+        System.out.println(System.currentTimeMillis() - start);
     }
 
 }

+ 19 - 5
4dkankan-utils-redis/src/main/java/com/fdkankan/redis/constant/RedisKey.java

@@ -1,27 +1,37 @@
 package com.fdkankan.redis.constant;
 
-public class RedisKey {
+import java.util.concurrent.TimeUnit;
 
+public class RedisKey {
     /**
      * 过期时间:1分钟
      */
-    public static int EXPIRE_TIME_1_MINUTE = 1*60*1000;
+    public static final int EXPIRE_TIME_1_MINUTE = 60;
 
     /**
      * 过期时间:10分钟
      */
-    public static int EXPIRE_TIME_10_MINUTE = 10*60*1000;
+    public static final int EXPIRE_TIME_10_MINUTE = 10*60;
 
     /**
      * 过期时间:30分钟
      */
-    public static int EXPIRE_TIME_30_MINUTE = 30*60*1000;
+    public static final int EXPIRE_TIME_30_MINUTE = 30*60;
 
     /**
      * 过期时间:2小时
      */
-    public static int EXPIRE_TIME_2_HOUR = 2*60*60*1000;
+    public static final int EXPIRE_TIME_2_HOUR = 2*60*60;
 
+    /**
+     * 用户过期时间
+     */
+    public static final int USER_EXPIRE_TIME = 6*60*60;
+
+    /**
+     * 相机登陆7天有效期
+     */
+    public static final int CAMERA_EXPIRE_7_TIME = 7*24*60*60;
 
     public static final String SYSTEM_PREFIX = "4dkankan";
 
@@ -31,6 +41,10 @@ public class RedisKey {
     public static String TOKEN_USER = "token:type:%s:name:%s";
 
     /**
+     * ssouser key
+     */
+    public static String SSO_USER = "sso_user:name:%s";
+    /**
      * 开发者信息
      */
     public static String TM_DEVELOPER = "developer:appid:%s";

+ 6 - 0
4dkankan-utils-redis/src/main/java/com/fdkankan/redis/util/RedisUtil.java

@@ -6,6 +6,8 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 
+import java.time.Duration;
+import java.time.temporal.ChronoUnit;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -543,4 +545,8 @@ public class RedisUtil<K, V>{
             return 0;
         }
     }
+
+    public void expire(String key,Duration time){
+        redisTemplate.expire(key, time);
+    }
 }