|
|
|
@ -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,6 +143,13 @@ public class TokenService
|
|
|
|
|
*/
|
|
|
|
|
public void refreshToken(LoginUser loginUser)
|
|
|
|
|
{
|
|
|
|
|
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缓存
|
|
|
|
@ -147,6 +157,8 @@ public class TokenService
|
|
|
|
|
redisCache.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 设置用户代理信息
|
|
|
|
|
*
|
|
|
|
|