|
@@ -8,7 +8,10 @@
|
|
package cn.com.qmth.examcloud.app.service.impl;
|
|
package cn.com.qmth.examcloud.app.service.impl;
|
|
|
|
|
|
import cn.com.qmth.examcloud.app.core.exception.ApiException;
|
|
import cn.com.qmth.examcloud.app.core.exception.ApiException;
|
|
-import cn.com.qmth.examcloud.app.core.utils.*;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.app.core.utils.HttpClientBuilder;
|
|
|
|
+import cn.com.qmth.examcloud.app.core.utils.HttpUtils;
|
|
|
|
+import cn.com.qmth.examcloud.app.core.utils.JsonMapper;
|
|
|
|
+import cn.com.qmth.examcloud.app.core.utils.ThreadUtils;
|
|
import cn.com.qmth.examcloud.app.model.*;
|
|
import cn.com.qmth.examcloud.app.model.*;
|
|
import cn.com.qmth.examcloud.app.service.PropertyService;
|
|
import cn.com.qmth.examcloud.app.service.PropertyService;
|
|
import cn.com.qmth.examcloud.app.service.RedisService;
|
|
import cn.com.qmth.examcloud.app.service.RedisService;
|
|
@@ -86,8 +89,7 @@ public class UserAuthServiceImpl implements UserAuthService {
|
|
.add(PARAM_TOKEN, token)
|
|
.add(PARAM_TOKEN, token)
|
|
.build();
|
|
.build();
|
|
//清除缓存用户登录信息
|
|
//清除缓存用户登录信息
|
|
- String redisKey = StrUtils.md5Key(key);
|
|
|
|
- this.removeCacheLoginInfo(redisKey);
|
|
|
|
|
|
+ this.removeCacheLoginInfo(key);
|
|
//退出登录
|
|
//退出登录
|
|
return HttpUtils.doPost(requestUrl, formBody, key, token);
|
|
return HttpUtils.doPost(requestUrl, formBody, key, token);
|
|
}
|
|
}
|
|
@@ -141,33 +143,33 @@ public class UserAuthServiceImpl implements UserAuthService {
|
|
* 缓存用户登录信息
|
|
* 缓存用户登录信息
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public void cacheLoginInfo(LoginInfo loginInfo, String redisKey) {
|
|
|
|
- if (StringUtils.isEmpty(redisKey)) {
|
|
|
|
- throw new ApiException("Key must be not empty.");
|
|
|
|
|
|
+ public void cacheLoginInfo(LoginInfo loginInfo, String key) {
|
|
|
|
+ if (StringUtils.isEmpty(key)) {
|
|
|
|
+ throw new ApiException("key must be not empty.");
|
|
}
|
|
}
|
|
String jsonStr = new JsonMapper().toJson(loginInfo);
|
|
String jsonStr = new JsonMapper().toJson(loginInfo);
|
|
- redisService.set(APP_SESSION_USER_KEY_PREFIX + redisKey, jsonStr, APP_SESSION_EXPIRE_TIME);
|
|
|
|
|
|
+ redisService.set(APP_SESSION_USER_KEY_PREFIX + key, jsonStr, APP_SESSION_EXPIRE_TIME);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 清除缓存用户登录信息
|
|
* 清除缓存用户登录信息
|
|
*/
|
|
*/
|
|
- private void removeCacheLoginInfo(String redisKey) {
|
|
|
|
- if (StringUtils.isEmpty(redisKey)) {
|
|
|
|
- throw new ApiException("redisKey must be not empty.");
|
|
|
|
|
|
+ private void removeCacheLoginInfo(String key) {
|
|
|
|
+ if (StringUtils.isEmpty(key)) {
|
|
|
|
+ throw new ApiException("key must be not empty.");
|
|
}
|
|
}
|
|
- redisService.delete(APP_SESSION_USER_KEY_PREFIX + redisKey);
|
|
|
|
|
|
+ redisService.delete(APP_SESSION_USER_KEY_PREFIX + key);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取缓存中的用户登录信息
|
|
* 获取缓存中的用户登录信息
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public LoginInfo getLoginInfo(String redisKey) {
|
|
|
|
- if (StringUtils.isEmpty(redisKey)) {
|
|
|
|
- throw new ApiException("redisKey must be not empty.");
|
|
|
|
|
|
+ public LoginInfo getLoginInfo(String key) {
|
|
|
|
+ if (StringUtils.isEmpty(key)) {
|
|
|
|
+ throw new ApiException("key must be not empty.");
|
|
}
|
|
}
|
|
- return redisService.fromJson(APP_SESSION_USER_KEY_PREFIX + redisKey, LoginInfo.class);
|
|
|
|
|
|
+ return redisService.fromJson(APP_SESSION_USER_KEY_PREFIX + key, LoginInfo.class);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|