|
@@ -217,53 +217,7 @@ public class LogAspect
|
|
|
return o instanceof MultipartFile || o instanceof HttpServletRequest || o instanceof HttpServletResponse;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 定义切点
|
|
|
- */
|
|
|
- @Pointcut("execution(public * com.miaxis.*.controller..*(..))")
|
|
|
- public void cutController() {
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 环绕通知
|
|
|
- * ProceedingJoinPoint:连接点对象
|
|
|
- */
|
|
|
- @Around("cutController()")
|
|
|
- public Object recordSysLog(ProceedingJoinPoint point) throws Throwable {
|
|
|
- long startTime = System.currentTimeMillis();
|
|
|
- // 定义返回对象
|
|
|
- Object resultData = null;
|
|
|
|
|
|
- //获取方法名
|
|
|
- String strMethodName = point.getSignature().getName();
|
|
|
- //获取类名
|
|
|
- String strClassName = point.getTarget().getClass().getName();
|
|
|
- //获取连接点方法运行时的入参列表
|
|
|
- Object[] params = point.getArgs();
|
|
|
- StringBuffer bfParams = new StringBuffer();
|
|
|
- Enumeration<String> paraNames = null;
|
|
|
- HttpServletRequest request = null;
|
|
|
- if (params != null && params.length > 0) {
|
|
|
- request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
|
- paraNames = request.getParameterNames();
|
|
|
- String key;
|
|
|
- String value;
|
|
|
- while (paraNames.hasMoreElements()) {
|
|
|
- key = paraNames.nextElement();
|
|
|
- value = request.getParameter(key);
|
|
|
- bfParams.append(key).append("=").append(value).append("&");
|
|
|
- }
|
|
|
- if (StringUtils.isBlank(bfParams)) {
|
|
|
- bfParams.append(request.getQueryString());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- log.info("=========>请求["+strMethodName+"]接口开始,类名:{},参数:{}", strClassName,bfParams.toString());
|
|
|
- resultData = point.proceed(params);
|
|
|
- long endTime = System.currentTimeMillis();
|
|
|
- log.info("======>请求["+strMethodName+"]接口结束,耗时:{}ms", (endTime - startTime));
|
|
|
- return resultData;
|
|
|
- }
|
|
|
|
|
|
|
|
|
}
|