Przeglądaj źródła

添加扩展值

李进 2 lat temu
rodzic
commit
f65492ec2b

+ 1 - 1
authorize-sdk/src/main/java/com/xy/consts/CommConsts.java

@@ -25,6 +25,6 @@ public class CommConsts {
     /**
      * token有效期,单位:s
      */
-    public static final Integer TOKEN_TIMEOUT = 3600;
+    public static final Integer TOKEN_TIMEOUT = 1800;
 
 }

+ 30 - 0
authorize-sdk/src/main/java/com/xy/utils/AuthorizeUtils.java

@@ -528,6 +528,36 @@ public class AuthorizeUtils {
         return authByData(getToken(), systemId, uri);
     }
 
+    /**
+     * 保存扩展值
+     *
+     * @param token
+     * @param expand
+     */
+    public static void setExpand(String token, String expand) {
+        RedisService<String> redisService = SpringBeanUtils.getBean(RedisService.class);
+        redisService.set("satoken:expand:" + token, expand, CommConsts.TOKEN_TIMEOUT);
+    }
+
+    /**
+     * 获取扩展值
+     *
+     * @return
+     */
+    public static String getExpand() {
+        RedisService<String> redisService = SpringBeanUtils.getBean(RedisService.class);
+        return redisService.get("satoken:expand:" + getToken());
+    }
+
+    /**
+     * 扩展值续签
+     */
+    public static void renewTimeoutExpand() {
+        String expand = getExpand();
+        RedisService<String> redisService = SpringBeanUtils.getBean(RedisService.class);
+        redisService.set("satoken:expand:" + getToken(), expand, CommConsts.TOKEN_TIMEOUT);
+    }
+
     @Data
     @Accessors(chain = true)
     public static class CacheEntity implements Serializable {