Commit 5a780e07 authored by yanzg's avatar yanzg

下载视频

parent 87e374fe
......@@ -3,7 +3,6 @@ package com.yanzuoguang.token;
import com.yanzuoguang.util.YzgError;
import com.yanzuoguang.util.base.ObjectHelper;
import com.yanzuoguang.util.cache.MemoryCache;
import com.yanzuoguang.util.exception.CodeException;
import com.yanzuoguang.util.helper.JsonHelper;
import com.yanzuoguang.util.helper.StringHelper;
import com.yanzuoguang.util.vo.MapRow;
......@@ -73,6 +72,18 @@ public class TokenHelper {
* @return 缓存的数据
*/
public static <T extends Object> T get(boolean checkFlag, Class<T> cls) {
return get(checkFlag, cls, true);
}
/**
* 获取当前的登录信息
*
* @param checkFlag 是否抛出异常
* @param cls 需要获取的数据的类型
* @param <T> 数据类型
* @return 缓存的数据
*/
public static <T extends Object> T get(boolean checkFlag, Class<T> cls, boolean readNewToken) {
String id = getCurrentId();
TokenData tokenData = cache.get(id);
if (tokenData == null) {
......@@ -81,6 +92,8 @@ public class TokenHelper {
}
return null;
}
// 获取最新的token
if (readNewToken) {
boolean isEmpty = tokenData.getData() == null || tokenData.getData().isEmpty();
boolean isExpire = tokenData.getExpire() < System.currentTimeMillis();
boolean isToken = !StringHelper.isEmpty(tokenData.getToken()) && (isEmpty || isExpire);
......@@ -96,6 +109,7 @@ public class TokenHelper {
}
return null;
}
}
if (ObjectHelper.isSub(cls, tokenData.getData().getClass())) {
return (T) tokenData.getData();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment