供应商-客户中间表引用表的新增修改删除修改
This commit is contained in:
@ -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<String> INTERCEPT_METHODS = Arrays.asList("POST", "PUT", "DELETE");
|
||||
|
||||
// 需要提取的请求体字段(根据实际需求修改)
|
||||
private static final List<String> EXTRACT_FIELDS = Arrays.asList("id",
|
||||
@ -130,7 +126,9 @@ public class RequestLogInterceptor implements HandlerInterceptor {
|
||||
|
||||
String uri = (String) cachedData.get("uri");
|
||||
Map<String, Object> extractedParams = (Map<String, Object>) 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<String, Object> 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<XzdCustomerSupplierYyb>().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));
|
||||
|
||||
Reference in New Issue
Block a user