From afa0dbb4f54e7244835dd67ec33c3e545f122f71 Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期五, 17 一月 2025 16:40:43 +0800
Subject: [PATCH] bug修改

---
 ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java |   46 +++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java b/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java
index 5220e2a..9b060f6 100644
--- a/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java
+++ b/ruoyi-common/ruoyi-common-log/src/main/java/com/ruoyi/common/log/aspect/LogAspect.java
@@ -1,6 +1,8 @@
 package com.ruoyi.common.log.aspect;
 
 import com.alibaba.fastjson2.JSON;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
 import com.ruoyi.common.core.utils.ServletUtils;
 import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.core.utils.ip.IpUtils;
@@ -28,6 +30,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -114,13 +117,14 @@
             getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
             // 设置消耗时间
             operLog.setCostTime(System.currentTimeMillis() - TIME_THREADLOCAL.get());
+            log.info("日志打印"+operLog.toString());
             // 保存数据库
             asyncLogService.saveSysLog(operLog);
         }
         catch (Exception exp)
         {
             // 记录本地异常日志
-            log.error("异常信息:{}", exp.getMessage());
+            log.error("日志异常信息:{}", exp.getMessage());
             exp.printStackTrace();
         }
         finally
@@ -155,7 +159,7 @@
         // 是否需要保存response,参数和值
         if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult))
         {
-            operLog.setJsonResult(StringUtils.substring(JSON.toJSONString(jsonResult), 0, 2000));
+            operLog.setJsonResult(StringUtils.substring(JSON.toJSONString(jsonResult), 0, 5000));
         }
     }
 
@@ -173,7 +177,43 @@
                 && (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod)))
         {
             String params = argsArrayToString(joinPoint.getArgs(), excludeParamNames);
-            operLog.setOperParam(StringUtils.substring(params, 0, 2000));
+            if(operLog.getOperContent().equals("编辑商户")){
+                // 将JSON字符串转换为Map
+                ObjectMapper objectMapper = new ObjectMapper();
+                Map<String, String> jsonMap = new HashMap<>();
+                try {
+                    jsonMap = objectMapper.readValue(params, HashMap.class);
+                } catch (JsonProcessingException e) {
+                    e.printStackTrace();
+                }
+                // 从Map中删除指定的元素
+                jsonMap.remove("shopDetail");
+                // 将Map转换回JSON字符串
+                try {
+                    params = objectMapper.writeValueAsString(jsonMap);
+                } catch (JsonProcessingException e) {
+                    e.printStackTrace();
+                }
+            }
+            if(operLog.getOperContent().equals("编辑商品")){
+                // 将JSON字符串转换为Map
+                ObjectMapper objectMapper = new ObjectMapper();
+                Map<String, String> jsonMap = new HashMap<>();
+                try {
+                    jsonMap = objectMapper.readValue(params, HashMap.class);
+                } catch (JsonProcessingException e) {
+                    e.printStackTrace();
+                }
+                // 从Map中删除指定的元素
+                jsonMap.remove("goodsDetail");
+                // 将Map转换回JSON字符串
+                try {
+                    params = objectMapper.writeValueAsString(jsonMap);
+                } catch (JsonProcessingException e) {
+                    e.printStackTrace();
+                }
+            }
+            operLog.setOperParam(StringUtils.substring(params, 0, 5000));
         }
         else
         {

--
Gitblit v1.7.1