Răsfoiți Sursa

fix(backend): 知识库查询删除接口契约对齐请求体并容错

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
E2E Test Bot 3 săptămâni în urmă
părinte
comite
2cd5eeffa6

+ 14 - 6
cfc-backend/src/main/java/com/etotem/cfc/controller/admin/KnowledgeBaseController.java

@@ -48,12 +48,15 @@ public class KnowledgeBaseController {
     }
 
     @PostMapping("/get")
-    public Result<Map<String, Object>> get(@RequestParam Long id) {
-        Map<String, Object> result = danKnowledgeBaseService.getWithAssociations(id);
-        if (result == null) {
-            return Result.error("知识不存在");
+    public Result<Map<String, Object>> get(@RequestBody(required = false) Map<String, Object> body,
+                                           @RequestParam(required = false) Long id) {
+        if (body != null && body.get("id") != null) {
+            id = com.etotem.cfc.util.ParamUtils.getLong(body.get("id"));
         }
-        return Result.success(result);
+        if (id == null) return Result.error("id不能为空");
+        return danKnowledgeBaseService.getWithAssociations(id) != null
+                ? Result.success(danKnowledgeBaseService.getWithAssociations(id))
+                : Result.error("知识条目不存在");
     }
 
     @SuppressWarnings("unchecked")
@@ -90,7 +93,12 @@ public class KnowledgeBaseController {
     }
 
     @PostMapping("/delete")
-    public Result<Void> delete(@RequestParam Long id) {
+    public Result<Void> delete(@RequestBody(required = false) Map<String, Object> body,
+                               @RequestParam(required = false) Long id) {
+        if (body != null && body.get("id") != null) {
+            id = com.etotem.cfc.util.ParamUtils.getLong(body.get("id"));
+        }
+        if (id == null) return Result.error("id不能为空");
         boolean success = danKnowledgeBaseService.deleteKnowledge(id);
         return success ? Result.success(null) : Result.error("删除失败");
     }