Commit 11b53c6a by shentao

2022/7/20 AOPAround逻辑调整

parent a4d580a1
......@@ -25,6 +25,7 @@ import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
/**
* @author sjj
......@@ -48,6 +49,26 @@ public class AuthAspect {
}
@Around("auth()")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
ServletRequestAttributes servletRequestAttributes = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes());
HttpServletRequest request = servletRequestAttributes.getRequest();
String token = request.getHeader(jwtKey);
// 不存在token
if (null == token || Objects.equals("undefined", token)) {
return joinPoint.proceed();
}else {
Map<String, Object> tokenInfo = JwtUtil.unsign(token, Map.class);
String uid = tokenInfo.get(GenericAttribute.USER_ID).toString();
UserInfo userInfo = UserService.queryUserInfo(uid, request.getHeader("pid"));
UserThreadLocal.set(userInfo);
// todo 操作记录收集
Object proceed = joinPoint.proceed();
UserThreadLocal.clear();
return proceed;
}
}
// @Around("auth()")
public Object aroundCheckToken(ProceedingJoinPoint joinPoint) throws Throwable {
Signature signature = joinPoint.getSignature();
Method method = ((MethodSignature) signature).getMethod();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment