Răsfoiți Sursa

fix(S-cfc-155): health.report.create 使绿 - createReport reportType 取值校验(契约仅允许 physical_exam/gut_flora,拒绝空串/非法值,HealthReportCreateContractTest 2红/8绿→10绿)

Agnes Agent 22 ore în urmă
părinte
comite
3b90e26d6

+ 5 - 1
cfc-backend/src/main/java/com/etotem/cfc/controller/HealthReportController.java

@@ -239,9 +239,13 @@ public class HealthReportController {
         }
 
         String reportType = (String) params.get("reportType");
-        if (reportType == null) {
+        if (reportType == null || reportType.trim().isEmpty()) {
             return Result.error("reportType不能为空: physical_exam / gut_flora");
         }
+        // 契约 §4.59.2:reportType 仅允许 physical_exam / gut_flora,其余取值(空串/非法值)一律拒绝
+        if (!"physical_exam".equals(reportType) && !"gut_flora".equals(reportType)) {
+            return Result.error("不支持的reportType: physical_exam / gut_flora");
+        }
 
         // 构建报告主体
         HealthReport report = new HealthReport();