【fix sonar】LogRecordAspect文件
This commit is contained in:
+5
-8
@@ -1,28 +1,25 @@
|
|||||||
package com.jero.modules.ngalain.aop;
|
package com.jero.modules.ngalain.aop;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.lang.annotation.Around;
|
import org.aspectj.lang.annotation.Around;
|
||||||
import org.aspectj.lang.annotation.Pointcut;
|
import org.aspectj.lang.annotation.Pointcut;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.web.context.request.RequestAttributes;
|
import org.springframework.web.context.request.RequestAttributes;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 暂时注释掉,提高系统性能
|
// 暂时注释掉,提高系统性能
|
||||||
//@Aspect //定义一个切面
|
//@Aspect //定义一个切面
|
||||||
//@Configuration
|
//@Configuration
|
||||||
|
@Slf4j
|
||||||
public class LogRecordAspect {
|
public class LogRecordAspect {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(LogRecordAspect.class);
|
|
||||||
|
|
||||||
// 定义切点Pointcut
|
// 定义切点Pointcut
|
||||||
@Pointcut("execution(public * com.jero.modules.*.*.*Controller.*(..))")
|
@Pointcut("execution(public * com.jero.modules.*.*.*Controller.*(..))")
|
||||||
public void excudeService() {
|
public void excudeService() {
|
||||||
|
// do point
|
||||||
}
|
}
|
||||||
|
|
||||||
@Around("excudeService()")
|
@Around("excudeService()")
|
||||||
@@ -40,12 +37,12 @@ private static final Logger logger = LoggerFactory.getLogger(LogRecordAspect.cla
|
|||||||
uri = request.getRequestURI();
|
uri = request.getRequestURI();
|
||||||
queryString = request.getQueryString();
|
queryString = request.getQueryString();
|
||||||
}
|
}
|
||||||
logger.info("请求开始, 各个参数, url: {}, method: {}, uri: {}, params: {}", url, method, uri, queryString);
|
log.info("请求开始, 各个参数, url: {}, method: {}, uri: {}, params: {}", url, method, uri, queryString);
|
||||||
|
|
||||||
// result的值就是被拦截方法的返回值
|
// result的值就是被拦截方法的返回值
|
||||||
Object result = pjp.proceed();
|
Object result = pjp.proceed();
|
||||||
|
|
||||||
logger.info("请求结束,controller的返回值是 " + result);
|
log.info("请求结束,controller的返回值是 " + result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user