|
@@ -5,12 +5,9 @@ import cn.org.spring.wechar.config.BasicInfo;
|
|
import cn.org.spring.wechar.utils.CacheUtil;
|
|
import cn.org.spring.wechar.utils.CacheUtil;
|
|
import cn.org.spring.wechar.utils.CookieUtils;
|
|
import cn.org.spring.wechar.utils.CookieUtils;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
-import lombok.Data;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
-import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
-import org.springframework.util.AntPathMatcher;
|
|
|
|
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
|
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -27,9 +24,8 @@ import java.io.PrintWriter;
|
|
*/
|
|
*/
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
-@Data
|
|
|
|
|
|
+
|
|
@Component
|
|
@Component
|
|
-@ConfigurationProperties(prefix = "login-interceptor")
|
|
|
|
public class LoginUserInterceptor extends HandlerInterceptorAdapter {
|
|
public class LoginUserInterceptor extends HandlerInterceptorAdapter {
|
|
@Autowired
|
|
@Autowired
|
|
CacheUtil cacheUtil;
|
|
CacheUtil cacheUtil;
|
|
@@ -37,27 +33,11 @@ public class LoginUserInterceptor extends HandlerInterceptorAdapter {
|
|
@Autowired
|
|
@Autowired
|
|
BasicInfo basicInfo;
|
|
BasicInfo basicInfo;
|
|
|
|
|
|
- @Autowired
|
|
|
|
- AntPathMatcher antPathMatcher;
|
|
|
|
-
|
|
|
|
- private String excludePatterns = "";
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
|
String uri = request.getRequestURI();
|
|
String uri = request.getRequestURI();
|
|
-
|
|
|
|
System.out.println("request.getRequestURI():" + uri);
|
|
System.out.println("request.getRequestURI():" + uri);
|
|
- System.out.println("不拦截路径信息:" + excludePatterns);
|
|
|
|
-
|
|
|
|
- String[] split = excludePatterns.split(",");
|
|
|
|
- for (String s : split) {
|
|
|
|
- boolean match = antPathMatcher.match(s, uri);
|
|
|
|
- if (match) {
|
|
|
|
- log.info("匹配到不拦截的路径:【{}】", s);
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
|
|
String cookieValue = CookieUtils.getCookieValue(request, "wechat-token");
|
|
String cookieValue = CookieUtils.getCookieValue(request, "wechat-token");
|
|
Object o = cacheUtil.get("wechatuser:" + cookieValue);
|
|
Object o = cacheUtil.get("wechatuser:" + cookieValue);
|