This commit is contained in:
2025-01-11 02:00:41 +08:00
parent f693f036df
commit ad9e91cd7a
11 changed files with 36 additions and 20 deletions

View File

@@ -1,10 +1,12 @@
package com.ycwl.basic.aspectj;
import com.alibaba.fastjson.JSON;
import com.ycwl.basic.annotation.IgnoreLogReq;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -13,6 +15,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
@@ -35,6 +38,12 @@ public class RequestParameterAspectj {
@Around("classPackage()")
public Object parameterPoint(ProceedingJoinPoint joinPoint) throws Throwable {
// 方法有 IgnoreLogReq 注解时不执行
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method callMethod = signature.getMethod();
if (callMethod.isAnnotationPresent(IgnoreLogReq.class)) {
return joinPoint.proceed();
}
final ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
if (requestAttributes != null) {
final HttpServletRequest request = requestAttributes.getRequest();