|
@@ -123,6 +123,7 @@ public class TokenService {
|
|
|
* @return 令牌
|
|
|
*/
|
|
|
public String createToken(LoginUser loginUser) {
|
|
|
+ Integer tokens = 0;
|
|
|
String token = IdUtils.fastUUID();
|
|
|
// String token = loginUser.getUserId();
|
|
|
loginUser.setToken(token);
|
|
@@ -132,7 +133,13 @@ public class TokenService {
|
|
|
Map<String, Object> claims = new HashMap<>();
|
|
|
claims.put(Constants.LOGIN_USER_KEY, token);
|
|
|
String token1 = createToken(claims);
|
|
|
- redisCache.setCacheObject(loginUser.getUsername(), token1, expireTime, TimeUnit.MINUTES);
|
|
|
+ List<SysDictData> data = dictTypeService.selectDictDataByType("expire_time");
|
|
|
+ if (!ObjectUtils.isEmpty(data.get(0).getDictValue())) {
|
|
|
+ tokens = Integer.valueOf(data.get(0).getDictValue());
|
|
|
+ } else {
|
|
|
+ tokens = expireTime;
|
|
|
+ }
|
|
|
+ redisCache.setCacheObject(loginUser.getUsername(), token1, tokens, TimeUnit.MINUTES);
|
|
|
return token1;
|
|
|
}
|
|
|
|
|
@@ -176,12 +183,18 @@ public class TokenService {
|
|
|
* @param loginUser 登录信息
|
|
|
*/
|
|
|
public void refreshToken(LoginUser loginUser) {
|
|
|
+ Integer tokens=0;
|
|
|
loginUser.setLoginTime(System.currentTimeMillis());
|
|
|
loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE);
|
|
|
// 根据uuid将loginUser缓存
|
|
|
String userKey = getTokenKey(loginUser.getToken());
|
|
|
List<SysDictData> data = dictTypeService.selectDictDataByType("expire_time");
|
|
|
- redisCache.setCacheObject(userKey, loginUser, Integer.valueOf(data.get(0).getDictValue()), TimeUnit.MINUTES);
|
|
|
+ if (!ObjectUtils.isEmpty(data.get(0).getDictValue())) {
|
|
|
+ tokens = Integer.valueOf(data.get(0).getDictValue());
|
|
|
+ } else {
|
|
|
+ tokens = expireTime;
|
|
|
+ }
|
|
|
+ redisCache.setCacheObject(userKey, loginUser, tokens, TimeUnit.MINUTES);
|
|
|
}
|
|
|
|
|
|
/**
|