接口执行时间
This commit is contained in:
parent
12ed8f03d3
commit
3a66ec6eda
|
|
@ -1,6 +1,7 @@
|
||||||
package com.sqx.common.aspect;
|
package com.sqx.common.aspect;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import com.sqx.common.utils.DateUtils;
|
||||||
import com.sqx.common.utils.HttpContextUtils;
|
import com.sqx.common.utils.HttpContextUtils;
|
||||||
import com.sqx.common.utils.IPUtils;
|
import com.sqx.common.utils.IPUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -12,6 +13,7 @@ import org.aspectj.lang.reflect.MethodSignature;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 方法调用统一切面处理
|
* 方法调用统一切面处理
|
||||||
|
|
@ -29,6 +31,7 @@ public class AppApiMethodAspect {
|
||||||
@Around("pkg()")
|
@Around("pkg()")
|
||||||
// @SuppressWarnings("unchecked")
|
// @SuppressWarnings("unchecked")
|
||||||
public Object around(ProceedingJoinPoint pjp) throws Throwable {
|
public Object around(ProceedingJoinPoint pjp) throws Throwable {
|
||||||
|
String start = DateUtils.format(new Date());
|
||||||
// 执行被拦截的方法
|
// 执行被拦截的方法
|
||||||
Object result = pjp.proceed();
|
Object result = pjp.proceed();
|
||||||
//请求的参数
|
//请求的参数
|
||||||
|
|
@ -37,8 +40,9 @@ public class AppApiMethodAspect {
|
||||||
String resultJson = new Gson().toJson(result);
|
String resultJson = new Gson().toJson(result);
|
||||||
//获取request
|
//获取request
|
||||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
||||||
log.info("\n>>>>>> {} {}\n>>>>>> {}\n>>>>>> Request: {}\n>>>>>> Response: {}",
|
String end = DateUtils.format(new Date());
|
||||||
request.getMethod(), request.getRequestURL(), IPUtils.getIpAddr(request),
|
log.info("\n>>>>>> 开始时间:{} 结束时间:{} \n>>>>>> {} {}\n>>>>>> {}\n>>>>>> Request: {}\n>>>>>> Response: {}",
|
||||||
|
start,end,request.getMethod(), request.getRequestURL(), IPUtils.getIpAddr(request),
|
||||||
params,
|
params,
|
||||||
resultJson
|
resultJson
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue