|
@@ -1,6 +1,7 @@
|
|
package com.fdkankan.ucenter.interceptor;
|
|
package com.fdkankan.ucenter.interceptor;
|
|
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.extra.servlet.ServletUtil;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.fdkankan.common.util.JwtUtil;
|
|
import com.fdkankan.common.util.JwtUtil;
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
@@ -8,6 +9,7 @@ import com.fdkankan.redis.util.RedisUtil;
|
|
import com.fdkankan.ucenter.common.RedisKeyUtil;
|
|
import com.fdkankan.ucenter.common.RedisKeyUtil;
|
|
import com.fdkankan.ucenter.common.Result;
|
|
import com.fdkankan.ucenter.common.Result;
|
|
import com.fdkankan.ucenter.constant.LoginConstant;
|
|
import com.fdkankan.ucenter.constant.LoginConstant;
|
|
|
|
+import com.fdkankan.ucenter.service.ILoginLogService;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -24,6 +26,8 @@ public class UcenterInterceptor implements HandlerInterceptor {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private RedisUtil redisUtil;
|
|
private RedisUtil redisUtil;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ILoginLogService loginLogService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
|
@@ -36,6 +40,7 @@ public class UcenterInterceptor implements HandlerInterceptor {
|
|
try {
|
|
try {
|
|
String redisKey = String.format(RedisKey.TOKEN_V3,token);
|
|
String redisKey = String.format(RedisKey.TOKEN_V3,token);
|
|
if(redisUtil.hasKey(redisKey)){
|
|
if(redisUtil.hasKey(redisKey)){
|
|
|
|
+ loginLogService.addLog(ServletUtil.getClientIP(request),token);
|
|
redisUtil.expire(redisKey,2 * 60 * 60);
|
|
redisUtil.expire(redisKey,2 * 60 * 60);
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|