|
|
@@ -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("删除失败");
|
|
|
}
|