|
|
@@ -0,0 +1,50 @@
|
|
|
+package com.etotem.cfc.controller;
|
|
|
+
|
|
|
+import com.etotem.cfc.common.Result;
|
|
|
+import com.etotem.cfc.entity.HealthKnowledgeBase;
|
|
|
+import com.etotem.cfc.service.HealthKnowledgeBaseService;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Slf4j
|
|
|
+@Tag(name = "健康知识库")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/health/knowledge")
|
|
|
+public class HealthKnowledgeBaseController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private HealthKnowledgeBaseService healthKnowledgeBaseService;
|
|
|
+
|
|
|
+ @Operation(summary = "查询知识库条目")
|
|
|
+ @PostMapping("/query")
|
|
|
+ public Result<HealthKnowledgeBase> query(@RequestBody Map<String, String> params) {
|
|
|
+ String itemType = params.get("itemType");
|
|
|
+ String itemName = params.get("itemName");
|
|
|
+ if (itemType == null || itemName == null) {
|
|
|
+ return Result.error("itemType和itemName不能为空");
|
|
|
+ }
|
|
|
+ HealthKnowledgeBase entry = healthKnowledgeBaseService.query(itemType, itemName);
|
|
|
+ return Result.success(entry);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Operation(summary = "批量查询知识库")
|
|
|
+ @PostMapping("/batch-query")
|
|
|
+ public Result<Map<String, HealthKnowledgeBase>> batchQuery(@RequestBody Map<String, Object> params) {
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ List<Map<String, String>> queries = (List<Map<String, String>>) params.get("queries");
|
|
|
+ if (queries == null || queries.isEmpty()) {
|
|
|
+ return Result.error("queries不能为空");
|
|
|
+ }
|
|
|
+ Map<String, HealthKnowledgeBase> result = healthKnowledgeBaseService.batchQuery(queries);
|
|
|
+ return Result.success(result);
|
|
|
+ }
|
|
|
+}
|