|
@@ -20,6 +20,7 @@ import org.aspectj.lang.JoinPoint;
|
|
|
import org.aspectj.lang.annotation.AfterReturning;
|
|
import org.aspectj.lang.annotation.AfterReturning;
|
|
|
import org.aspectj.lang.annotation.AfterThrowing;
|
|
import org.aspectj.lang.annotation.AfterThrowing;
|
|
|
import org.aspectj.lang.annotation.Aspect;
|
|
import org.aspectj.lang.annotation.Aspect;
|
|
|
|
|
+import org.aspectj.lang.annotation.Pointcut;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
@@ -38,12 +39,20 @@ public class LogAspect {
|
|
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(LogAspect.class);
|
|
private static final Logger log = LoggerFactory.getLogger(LogAspect.class);
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 定义默认切入点
|
|
|
|
|
+ */
|
|
|
|
|
+ @Pointcut(value = "execution(* com.railway..*.controller..*.*(..))")
|
|
|
|
|
+ private void controllerMethod() {
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 处理完请求后执行
|
|
* 处理完请求后执行
|
|
|
*
|
|
*
|
|
|
* @param joinPoint 切点
|
|
* @param joinPoint 切点
|
|
|
*/
|
|
*/
|
|
|
- @AfterReturning(pointcut = "@annotation(controllerLog)", returning = "jsonResult")
|
|
|
|
|
|
|
+ @AfterReturning(value = "controllerMethod()",
|
|
|
|
|
+ pointcut = "@annotation(controllerLog)", returning = "jsonResult")
|
|
|
public void doAfterReturning(JoinPoint joinPoint, Log controllerLog, Object jsonResult) {
|
|
public void doAfterReturning(JoinPoint joinPoint, Log controllerLog, Object jsonResult) {
|
|
|
handleLog(joinPoint, controllerLog, null, jsonResult);
|
|
handleLog(joinPoint, controllerLog, null, jsonResult);
|
|
|
}
|
|
}
|