From 769e476b23a04133584e304cbd9a22d83339af20 Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Mon, 30 Dec 2024 16:42:32 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E6=97=A5=E5=BF=97=20?= =?UTF-8?q?=E5=BC=82=E6=AD=A5=E6=89=93=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sqx/common/aspect/AppApiMethodAspect.java | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/sqx/common/aspect/AppApiMethodAspect.java b/src/main/java/com/sqx/common/aspect/AppApiMethodAspect.java index b7315939..ed6f6707 100644 --- a/src/main/java/com/sqx/common/aspect/AppApiMethodAspect.java +++ b/src/main/java/com/sqx/common/aspect/AppApiMethodAspect.java @@ -1,5 +1,6 @@ package com.sqx.common.aspect; +import cn.hutool.core.thread.ThreadUtil; import com.google.gson.Gson; import com.sqx.common.utils.HttpContextUtils; import com.sqx.common.utils.IPUtils; @@ -44,22 +45,27 @@ public class AppApiMethodAspect { // 执行被拦截的方法 Object result = pjp.proceed(); - - //请求的参数 - String resultJson = new Gson().toJson(result); - try{ - HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); - long end = System.currentTimeMillis(); - if(StringUtils.isNotBlank(resultJson) && !"null".equals(resultJson)){ - log.info("\n>>>>>> {} {}\n>>>>>> IP: {} \n>>>>>> execute time:{}ms \n>>>>>> Request: {}\n>>>>>> Response: {}", - request.getMethod(), request.getRequestURL(), IPUtils.getIpAddr(request),end-start, - params, - resultJson - ); + long end = System.currentTimeMillis(); + ThreadUtil.execAsync(() -> { + //请求的参数 + String resultJson = new Gson().toJson(result); + try { + HttpServletRequest request = HttpContextUtils.getHttpServletRequest(); + if (StringUtils.isNotBlank(resultJson) && !"null".equals(resultJson)) { + log.info("\n>>>>>> {} {}" + + "\n>>>>>> IP: {} " + + "\n>>>>>> execute time:{}ms " + + "\n>>>>>> Request: {}" + + "\n>>>>>> Response: {}", + request.getMethod(), request.getRequestURL(), IPUtils.getIpAddr(request), end - start, + params, + resultJson + ); + } + } catch (Exception e) { + log.error("Request 为空" + e.getMessage()); } - }catch (Exception e){ - log.error("Request 为空"+e.getMessage()); - } + }); return result; } }