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