统一接口日志打印
This commit is contained in:
@@ -8,7 +8,6 @@ import com.czg.sa.StpKit;
|
|||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@@ -29,7 +28,7 @@ public class AdminOrderController {
|
|||||||
* 订单列表
|
* 订单列表
|
||||||
*/
|
*/
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public CzgResult<Page<OrderInfoVo>> getOrderPage(@RequestBody OrderInfoQueryDTO queryDTO) {
|
public CzgResult<Page<OrderInfoVo>> getOrderPage(OrderInfoQueryDTO queryDTO) {
|
||||||
queryDTO.setShopId(StpKit.USER.getShopId());
|
queryDTO.setShopId(StpKit.USER.getShopId());
|
||||||
return CzgResult.success(orderInfoService.getOrderByPage(queryDTO));
|
return CzgResult.success(orderInfoService.getOrderByPage(queryDTO));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import cn.hutool.core.thread.ThreadUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.czg.utils.ServletUtil;
|
import com.czg.utils.ServletUtil;
|
||||||
import com.google.gson.Gson;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
@@ -17,14 +16,16 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 方法调用统一切面处理
|
* 方法调用统一切面处理
|
||||||
|
* @author ww
|
||||||
*/
|
*/
|
||||||
@Aspect
|
@Aspect
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
//@Profile({"dev"})
|
@Profile({"test", "dev", "prod"})
|
||||||
|
//@Profile({"test"})
|
||||||
public class ControllerAspect {
|
public class ControllerAspect {
|
||||||
|
|
||||||
@Pointcut("execution(public * (com.czg.controller.*.controller..*).*(..)))")
|
@Pointcut("execution(public * (com.czg.controller..*).*(..)))")
|
||||||
public void pkg() {
|
public void pkg() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +42,7 @@ public class ControllerAspect {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String params = new Gson().toJson(args);
|
String params = JSONObject.toJSONString(args);
|
||||||
|
|
||||||
// 执行被拦截的方法
|
// 执行被拦截的方法
|
||||||
Object result = pjp.proceed();
|
Object result = pjp.proceed();
|
||||||
@@ -56,11 +57,14 @@ public class ControllerAspect {
|
|||||||
String resultJson = JSONObject.toJSONString(result);
|
String resultJson = JSONObject.toJSONString(result);
|
||||||
try {
|
try {
|
||||||
if (StrUtil.isNotBlank(resultJson) && !"null" .equals(resultJson)) {
|
if (StrUtil.isNotBlank(resultJson) && !"null" .equals(resultJson)) {
|
||||||
log.info("\n>>>>>> {} {}" +
|
log.info("""
|
||||||
"\n>>>>>> IP: {} " +
|
|
||||||
"\n>>>>>> execute time:{}ms " +
|
>>>>>> {} {}
|
||||||
"\n>>>>>> Request: {}" +
|
>>>>>> IP: {}
|
||||||
"\n>>>>>> Response: {}",
|
>>>>>> execute time:{}ms
|
||||||
|
>>>>>> Request: {}
|
||||||
|
>>>>>> Response: {}
|
||||||
|
""",
|
||||||
method, requestUrl, requestIp, useTime,
|
method, requestUrl, requestIp, useTime,
|
||||||
params,
|
params,
|
||||||
resultJson
|
resultJson
|
||||||
|
|||||||
Reference in New Issue
Block a user