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