Przeglądaj źródła

更新日志拦截器

DESKTOP-VAEGFGM\zqc 1 miesiąc temu
rodzic
commit
ab2c96c169

+ 10 - 2
citu-gateway/src/main/java/com/citu/gateway/filter/logging/AccessLogFilter.java

@@ -3,6 +3,7 @@ package com.citu.gateway.filter.logging;
 import cn.hutool.core.date.LocalDateTimeUtil;
 import cn.hutool.core.map.MapUtil;
 import cn.hutool.json.JSONUtil;
+import com.alibaba.nacos.common.utils.JacksonUtils;
 import com.citu.framework.common.util.json.JsonUtils;
 import com.citu.gateway.util.SecurityFrameworkUtils;
 import com.citu.gateway.util.WebFrameworkUtils;
@@ -81,12 +82,19 @@ public class AccessLogFilter implements GlobalFilter, Ordered {
         values.put("schema", gatewayLog.getSchema());
         values.put("requestUrl", gatewayLog.getRequestUrl());
         values.put("queryParams", gatewayLog.getQueryParams().toSingleValueMap());
+
         values.put("requestBody", JsonUtils.isJson(gatewayLog.getRequestBody()) ? // 保证 body 的展示好看
-                JSONUtil.parse(gatewayLog.getRequestBody()) : gatewayLog.getRequestBody());
+                        JacksonUtils.toObj(gatewayLog.getRequestBody()) : gatewayLog.getRequestBody());
+//                JSONUtil.parse(gatewayLog.getRequestBody()) : gatewayLog.getRequestBody());
+
+
         values.put("requestHeaders", JsonUtils.toJsonString(gatewayLog.getRequestHeaders().toSingleValueMap()));
         values.put("userIp", gatewayLog.getUserIp());
         values.put("responseBody", JsonUtils.isJson(gatewayLog.getResponseBody()) ? // 保证 body 的展示好看
-                JSONUtil.parse(gatewayLog.getResponseBody()) : gatewayLog.getResponseBody());
+                 JacksonUtils.toObj(gatewayLog.getResponseBody()) : gatewayLog.getRequestBody());
+//        JSONUtil.parse(gatewayLog.getResponseBody()) : gatewayLog.getResponseBody());
+
+
         values.put("responseHeaders", gatewayLog.getResponseHeaders() != null ?
                 JsonUtils.toJsonString(gatewayLog.getResponseHeaders().toSingleValueMap()) : null);
         values.put("httpStatus", gatewayLog.getHttpStatus());