mirror of
https://github.com/yangzongzhuan/RuoYi-Cloud.git
synced 2025-09-02 02:44:42 +00:00
优化代码
This commit is contained in:
@@ -540,9 +540,9 @@ public class Convert
|
||||
|
||||
/**
|
||||
* 转换为boolean<br>
|
||||
* String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* String支持的值为:true、false、yes、ok、no、1、0、是、否, 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
@@ -569,10 +569,12 @@ public class Convert
|
||||
case "yes":
|
||||
case "ok":
|
||||
case "1":
|
||||
case "是":
|
||||
return true;
|
||||
case "false":
|
||||
case "no":
|
||||
case "0":
|
||||
case "否":
|
||||
return false;
|
||||
default:
|
||||
return defaultValue;
|
||||
|
@@ -37,7 +37,7 @@ public class TableDataInfo implements Serializable
|
||||
* @param list 列表数据
|
||||
* @param total 总记录数
|
||||
*/
|
||||
public TableDataInfo(List<?> list, int total)
|
||||
public TableDataInfo(List<?> list, long total)
|
||||
{
|
||||
this.rows = list;
|
||||
this.total = total;
|
||||
|
@@ -36,11 +36,11 @@ public class TokenService
|
||||
|
||||
protected static final long MILLIS_MINUTE = 60 * MILLIS_SECOND;
|
||||
|
||||
private final static long expireTime = CacheConstants.EXPIRATION;
|
||||
private final static long TOKEN_EXPIRE_TIME = CacheConstants.EXPIRATION;
|
||||
|
||||
private final static String ACCESS_TOKEN = CacheConstants.LOGIN_TOKEN_KEY;
|
||||
|
||||
private final static Long MILLIS_MINUTE_TEN = CacheConstants.REFRESH_TIME * MILLIS_MINUTE;
|
||||
private final static Long TOKEN_REFRESH_THRESHOLD_MINUTES = CacheConstants.REFRESH_TIME * MILLIS_MINUTE;
|
||||
|
||||
/**
|
||||
* 创建令牌
|
||||
@@ -65,7 +65,7 @@ public class TokenService
|
||||
// 接口返回信息
|
||||
Map<String, Object> rspMap = new HashMap<String, Object>();
|
||||
rspMap.put("access_token", JwtUtils.createToken(claimsMap));
|
||||
rspMap.put("expires_in", expireTime);
|
||||
rspMap.put("expires_in", TOKEN_EXPIRE_TIME);
|
||||
return rspMap;
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ public class TokenService
|
||||
{
|
||||
long expireTime = loginUser.getExpireTime();
|
||||
long currentTime = System.currentTimeMillis();
|
||||
if (expireTime - currentTime <= MILLIS_MINUTE_TEN)
|
||||
if (expireTime - currentTime <= TOKEN_REFRESH_THRESHOLD_MINUTES)
|
||||
{
|
||||
refreshToken(loginUser);
|
||||
}
|
||||
@@ -161,10 +161,10 @@ public class TokenService
|
||||
public void refreshToken(LoginUser loginUser)
|
||||
{
|
||||
loginUser.setLoginTime(System.currentTimeMillis());
|
||||
loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE);
|
||||
loginUser.setExpireTime(loginUser.getLoginTime() + TOKEN_EXPIRE_TIME * MILLIS_MINUTE);
|
||||
// 根据uuid将loginUser缓存
|
||||
String userKey = getTokenKey(loginUser.getToken());
|
||||
redisService.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES);
|
||||
redisService.setCacheObject(userKey, loginUser, TOKEN_EXPIRE_TIME, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
private String getTokenKey(String token)
|
||||
|
Reference in New Issue
Block a user