refactor: 切面日志异常请求拦截处理

This commit is contained in:
fit2-zhao 2023-07-12 10:11:55 +08:00 committed by fit2-zhao
parent c57e63f8c4
commit f89bb88ac6
1 changed files with 8 additions and 4 deletions

View File

@ -12,10 +12,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.*;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature; import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.core.StandardReflectionParameterNameDiscoverer; import org.springframework.core.StandardReflectionParameterNameDiscoverer;
@ -72,6 +69,13 @@ public class OperationLogAspect {
public void logPointCut() { public void logPointCut() {
} }
@AfterThrowing(pointcut = "logPointCut()", throwing = "ex")
public void handleException(Exception ex) {
localUser.remove();
beforeValues.remove();
LogUtils.error(ex);
}
@Before("logPointCut()") @Before("logPointCut()")
public void before(JoinPoint joinPoint) { public void before(JoinPoint joinPoint) {
try { try {