|
@@ -1,7 +1,6 @@
|
|
|
package com.sxtvs.open.core.auth;
|
|
|
|
|
|
|
|
|
-import cn.hutool.core.util.IdUtil;
|
|
|
import com.sxtvs.open.core.advice.BizException;
|
|
|
import com.sxtvs.open.core.conf.Constant;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
@@ -13,12 +12,11 @@ import java.lang.reflect.Method;
|
|
|
|
|
|
public class LoginInterceptor implements AsyncHandlerInterceptor {
|
|
|
@Override
|
|
|
- public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
|
|
- if (!(handler instanceof HandlerMethod)) {
|
|
|
+ public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
|
|
+ if (!(handler instanceof HandlerMethod handlerMethod)) {
|
|
|
return true;
|
|
|
}
|
|
|
HttpContextUtil.setRequestId();
|
|
|
- HandlerMethod handlerMethod = (HandlerMethod) handler;
|
|
|
Method method = handlerMethod.getMethod();
|
|
|
|
|
|
LoginRequired methodAnnotation = method.getAnnotation(LoginRequired.class);
|
|
@@ -32,6 +30,7 @@ public class LoginInterceptor implements AsyncHandlerInterceptor {
|
|
|
if (!AESUtil.isOk(token)) {
|
|
|
throw new BizException("没有登录");
|
|
|
}
|
|
|
+ HttpContextUtil.setToken(token);
|
|
|
|
|
|
return true;
|
|
|
}
|