app登录时效修改

master
heminjian502 2 years ago
parent 97624a399a
commit a2ea6bb1d7

@ -71,6 +71,11 @@ public class LoginUser implements UserDetails
*/
private SysUser user;
/**
* 1:app/mp 2:
*/
private String requestFrom;
public Long getUserId()
{
return userId;
@ -263,4 +268,12 @@ public class LoginUser implements UserDetails
{
return null;
}
public String getRequestFrom() {
return requestFrom;
}
public void setRequestFrom(String requestFrom) {
this.requestFrom = requestFrom;
}
}

@ -124,7 +124,8 @@ public class SysLoginService
sysUser.setHospitalId(tDoctor.getHospitalId());
loginUser.setUserId(sysUser.getUserId());
loginUser.setUser(sysUser);
String token = userTokenService.createToken(loginUser);
loginUser.setRequestFrom("1");
String token = userTokenService.createTokenForApp(loginUser);
AsyncManager.me().execute(AsyncFactory.recordLogininfor(sysUser.getUserName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
recordLoginInfo(sysUser.getUserId());
ajax.put(Constants.TOKEN, token);
@ -195,6 +196,7 @@ public class SysLoginService
sysUser.setHospitalId(tDoctor.getHospitalId());
loginUser.setUserId(sysUser.getUserId());
loginUser.setUser(sysUser);
loginUser.setRequestFrom("1");
String token = userTokenService.createTokenForApp(loginUser);
AsyncManager.me().execute(AsyncFactory.recordLogininfor(sysUser.getUserName(), Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
AjaxResult ajaxResult = AjaxResult.success();

@ -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);
}
}
/**

Loading…
Cancel
Save