Explorar el Código

fix(S-cfc-311): admin.reportParser.manage saveType 显式置空 linkedProductId 改用字符串版 UpdateWrapper(消除 lambda cache 依赖,RED 3例转绿)

Sisyphus hace 2 días
padre
commit
cf10e6109

+ 8 - 6
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/ReportParserAdminController.java

@@ -1,7 +1,7 @@
 package com.etotem.cfc.controller.admin;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.etotem.cfc.common.Result;
 import com.etotem.cfc.entity.*;
@@ -120,13 +120,15 @@ public class ReportParserAdminController {
         if (type.getId() != null) {
             type.setUpdatedAt(new Date());
             typeRegistryMapper.updateById(type);
-            // MyBatis-Plus updateById 默认忽略 null 字段,linkedProductId 允许清空(=NULL 表示不可链接),需显式置空
+            // MyBatis-Plus updateById 默认忽略 null 字段,linkedProductId 允许清空(=NULL 表示不可链接),需显式置空。
+            // 使用字符串列名版 UpdateWrapper(非 Lambda 版),避免纯 Mockito 单测无 MyBatis-Plus 运行时环境
+            // 构造 LambdaUpdateWrapper 时抛 "can not find lambda cache for this entity"。
             if (type.getLinkedProductId() == null) {
                 typeRegistryMapper.update(null,
-                        new LambdaUpdateWrapper<ReportTypeRegistry>()
-                                .eq(ReportTypeRegistry::getId, type.getId())
-                                .set(ReportTypeRegistry::getLinkedProductId, null)
-                                .set(ReportTypeRegistry::getUpdatedAt, type.getUpdatedAt()));
+                        new UpdateWrapper<ReportTypeRegistry>()
+                                .eq("id", type.getId())
+                                .set("linked_product_id", null)
+                                .set("updated_at", type.getUpdatedAt()));
             }
         } else {
             Long exists = typeRegistryMapper.selectCount(