|
@@ -18,7 +18,6 @@ import cn.com.qmth.examcloud.web.enums.HttpServletRequestAttribute;
|
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
|
import cn.com.qmth.examcloud.web.support.ApiInfo;
|
|
|
import cn.com.qmth.examcloud.web.support.ServletUtil;
|
|
|
-import cn.com.qmth.examcloud.web.support.SpringContextHolder;
|
|
|
import cn.com.qmth.examcloud.web.support.StatusResponse;
|
|
|
|
|
|
/**
|
|
@@ -40,22 +39,16 @@ public class RequestPermissionInterceptor implements HandlerInterceptor {
|
|
|
|
|
|
private RedisClient redisClient;
|
|
|
|
|
|
- private RedisClient getRedisClient() {
|
|
|
- if (null == redisClient) {
|
|
|
- redisClient = SpringContextHolder.getBean(RedisClient.class);
|
|
|
- }
|
|
|
- return redisClient;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 构造函数
|
|
|
*
|
|
|
+ * @param resourceManager
|
|
|
* @param redisClient
|
|
|
- * @param exclusions
|
|
|
*/
|
|
|
- public RequestPermissionInterceptor(ResourceManager resourceManager) {
|
|
|
+ public RequestPermissionInterceptor(ResourceManager resourceManager, RedisClient redisClient) {
|
|
|
super();
|
|
|
this.resourceManager = resourceManager;
|
|
|
+ this.redisClient = redisClient;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -118,7 +111,7 @@ public class RequestPermissionInterceptor implements HandlerInterceptor {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- User user = getRedisClient().get(key, User.class);
|
|
|
+ User user = redisClient.get(key, User.class);
|
|
|
|
|
|
if (null == user) {
|
|
|
response.setStatus(HttpStatus.FORBIDDEN.value());
|
|
@@ -130,7 +123,7 @@ public class RequestPermissionInterceptor implements HandlerInterceptor {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- getRedisClient().expire(key, user.getSessionTimeout());
|
|
|
+ redisClient.expire(key, user.getSessionTimeout());
|
|
|
|
|
|
ThreadContext.put("CALLER", key);
|
|
|
|