|
|
|
@ -40,6 +40,9 @@ public class TokenService
|
|
|
|
|
@Value("${token.expireTime}")
|
|
|
|
|
private int expireTime;
|
|
|
|
|
|
|
|
|
|
@Value("${token.appExpireTime}")
|
|
|
|
|
private int appExpireTime;
|
|
|
|
|
|
|
|
|
|
protected static final long MILLIS_SECOND = 1000;
|
|
|
|
|
|
|
|
|
|
protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND;
|
|
|
|
@ -140,11 +143,20 @@ public class TokenService
|
|
|
|
|
*/
|
|
|
|
|
public void refreshToken(LoginUser loginUser)
|
|
|
|
|
{
|
|
|
|
|
loginUser.setLoginTime(System.currentTimeMillis());
|
|
|
|
|
loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE);
|
|
|
|
|
// 根据uuid将loginUser缓存
|
|
|
|
|
String userKey = getTokenKey(loginUser.getToken());
|
|
|
|
|
redisCache.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES);
|
|
|
|
|
if ("1".equals(loginUser.getRequestFrom())) {
|
|
|
|
|
loginUser.setLoginTime(System.currentTimeMillis());
|
|
|
|
|
loginUser.setExpireTime(loginUser.getLoginTime() + appExpireTime * MILLIS_MINUTE);
|
|
|
|
|
// 根据uuid将loginUser缓存
|
|
|
|
|
String userKey = getTokenKey(loginUser.getToken());
|
|
|
|
|
redisCache.setCacheObject(userKey, loginUser, appExpireTime, TimeUnit.MINUTES);
|
|
|
|
|
} else {
|
|
|
|
|
loginUser.setLoginTime(System.currentTimeMillis());
|
|
|
|
|
loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE);
|
|
|
|
|
// 根据uuid将loginUser缓存
|
|
|
|
|
String userKey = getTokenKey(loginUser.getToken());
|
|
|
|
|
redisCache.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|