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