From 6784eafe6e5107487c1dcc434c7833d3e253bdbf Mon Sep 17 00:00:00 2001 From: dfdg <2710245601@qq.com> Date: Sat, 25 Oct 2025 22:17:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86-=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E4=B8=AD=E9=97=B4=E8=A1=A8=E5=BC=95=E7=94=A8=E8=A1=A8=E7=9A=84?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BF=AE=E6=94=B9=E5=88=A0=E9=99=A4=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interceptor/RequestLogInterceptor.java | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/xzd/interceptor/RequestLogInterceptor.java b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/xzd/interceptor/RequestLogInterceptor.java index 25065416..ce4d8ef6 100644 --- a/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/xzd/interceptor/RequestLogInterceptor.java +++ b/xinnengyuan/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/xzd/interceptor/RequestLogInterceptor.java @@ -1,5 +1,6 @@ package org.dromara.xzd.interceptor; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -27,11 +28,6 @@ public class RequestLogInterceptor implements HandlerInterceptor { @Autowired private XzdCustomerSupplierYybMapper customerSupplierYybMapper; - @Autowired - private AutoIncrementIdHolder autoIncrementIdHolder; - - // 需要拦截的请求方法 - private static final List INTERCEPT_METHODS = Arrays.asList("POST", "PUT", "DELETE"); // 需要提取的请求体字段(根据实际需求修改) private static final List EXTRACT_FIELDS = Arrays.asList("id", @@ -130,7 +126,9 @@ public class RequestLogInterceptor implements HandlerInterceptor { String uri = (String) cachedData.get("uri"); Map extractedParams = (Map) cachedData.get("extractedParams"); - + if (extractedParams == null || extractedParams.isEmpty()) { + return; + } // 1. 尝试从请求参数获取ID(前端传入的情况,如非自增ID) Long newId = convertToLong(extractedParams.get("id")); // 2. 从AOP存入的ThreadLocal获取ID(数据库自增/雪花算法生成的情况) @@ -151,6 +149,12 @@ public class RequestLogInterceptor implements HandlerInterceptor { if ("id".equals(k)){ continue; } + if (ObjectUtil.isEmpty(v)) { + continue; + } + if (convertToLong(v) == null){ + continue; + } XzdCustomerSupplierYyb entity = new XzdCustomerSupplierYyb(); entity.setUri(uri); entity.setCSId(convertToLong(v)); @@ -167,6 +171,9 @@ public class RequestLogInterceptor implements HandlerInterceptor { private void handlePutOrDelete(HttpServletRequest request, String method) { String uri = request.getRequestURI(); Map extractedParams = RequestParamExtractor.extractParams(request, method, EXTRACT_FIELDS); + if (extractedParams == null || extractedParams.isEmpty()) { + return; + } if ("PUT".equals(method)) { Long mainTableId = convertToLong(extractedParams.get("id")); customerSupplierYybMapper.delete(new LambdaQueryWrapper().eq(XzdCustomerSupplierYyb::getMainTableId, mainTableId)); @@ -178,6 +185,12 @@ public class RequestLogInterceptor implements HandlerInterceptor { if ("id".equals(k)){ continue; } + if (ObjectUtil.isEmpty(v)) { + continue; + } + if (convertToLong(v) == null){ + continue; + } XzdCustomerSupplierYyb customerSupplierYyb = new XzdCustomerSupplierYyb(); customerSupplierYyb.setUri(uri); customerSupplierYyb.setCSId(convertToLong(v));