|
@@ -4,6 +4,7 @@ import org.aopalliance.intercept.MethodInterceptor;
|
|
|
import org.hswebframework.web.AopUtils;
|
|
|
import org.hswebframework.web.WebUtil;
|
|
|
import org.hswebframework.web.boost.aop.context.MethodInterceptorHolder;
|
|
|
+import org.hswebframework.web.id.IDGenerator;
|
|
|
import org.hswebframework.web.logging.AccessLogger;
|
|
|
import org.hswebframework.web.logging.AccessLoggerInfo;
|
|
|
import org.hswebframework.web.logging.AccessLoggerListener;
|
|
@@ -13,6 +14,7 @@ import org.springframework.core.Ordered;
|
|
|
import org.springframework.core.annotation.AnnotationUtils;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.util.ClassUtils;
|
|
|
+import org.springframework.util.SimpleIdGenerator;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -20,6 +22,7 @@ import java.lang.reflect.Method;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.UUID;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
@@ -50,6 +53,7 @@ public class AopAccessLoggerSupport extends StaticMethodMatcherPointcutAdvisor {
|
|
|
AccessLoggerInfo info = createLogger(methodInterceptorHolder);
|
|
|
Object response;
|
|
|
try {
|
|
|
+ listeners.forEach(listener -> listener.onLogBefore(info));
|
|
|
response = methodInvocation.proceed();
|
|
|
info.setResponse(response);
|
|
|
info.setResponseTime(System.currentTimeMillis());
|
|
@@ -66,6 +70,8 @@ public class AopAccessLoggerSupport extends StaticMethodMatcherPointcutAdvisor {
|
|
|
|
|
|
protected AccessLoggerInfo createLogger(MethodInterceptorHolder holder) {
|
|
|
AccessLoggerInfo info = new AccessLoggerInfo();
|
|
|
+ info.setId(IDGenerator.MD5.generate());
|
|
|
+
|
|
|
info.setRequestTime(System.currentTimeMillis());
|
|
|
|
|
|
|
|
@@ -101,9 +107,13 @@ public class AopAccessLoggerSupport extends StaticMethodMatcherPointcutAdvisor {
|
|
|
|
|
|
@Override
|
|
|
public boolean matches(Method method, Class<?> aClass) {
|
|
|
+ AccessLogger ann = AopUtils.findAnnotation(aClass, method, AccessLogger.class);
|
|
|
+ if(ann!=null&&ann.ignore()){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
RequestMapping mapping= AopUtils.findAnnotation(aClass,method, RequestMapping.class);
|
|
|
return mapping!=null;
|
|
|
-// AccessLogger ann = AopUtils.findAnnotation(aClass, method, AccessLogger.class);
|
|
|
+
|
|
|
// //注解了并且未取消
|
|
|
// return null != ann && !ann.ignore();
|
|
|
}
|