|
@@ -6,6 +6,7 @@ import com.etotem.cfc.service.HealthPlanService;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -19,7 +20,7 @@ public class HealthPlanController {
|
|
|
@Resource
|
|
@Resource
|
|
|
private HealthPlanService healthPlanService;
|
|
private HealthPlanService healthPlanService;
|
|
|
|
|
|
|
|
- @Operation(summary = "生成健康方案")
|
|
|
|
|
|
|
+ @Operation(summary = "生成健康方案(文本)")
|
|
|
@PostMapping("/generate")
|
|
@PostMapping("/generate")
|
|
|
public Result<String> generate(@RequestBody Map<String, Object> params,
|
|
public Result<String> generate(@RequestBody Map<String, Object> params,
|
|
|
@RequestAttribute("userId") Long userId,
|
|
@RequestAttribute("userId") Long userId,
|
|
@@ -34,7 +35,23 @@ public class HealthPlanController {
|
|
|
return Result.success(planContent);
|
|
return Result.success(planContent);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @Operation(summary = "保存健康方案")
|
|
|
|
|
|
|
+ @Operation(summary = "重新生成方案某一部分(营养/饮食/运动)")
|
|
|
|
|
+ @PostMapping("/regenerate-section")
|
|
|
|
|
+ public Result<String> regenerateSection(
|
|
|
|
|
+ @RequestBody Map<String, Object> params,
|
|
|
|
|
+ @RequestAttribute("userId") Long userId,
|
|
|
|
|
+ @RequestAttribute(value = "familyId", required = false) Long familyId) {
|
|
|
|
|
+ String section = (String) params.get("section");
|
|
|
|
|
+ String feedback = (String) params.get("feedback");
|
|
|
|
|
+ String planJsonStr = (String) params.get("planJson");
|
|
|
|
|
+ if (section == null || planJsonStr == null) {
|
|
|
|
|
+ return Result.error("section和planJson不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ String result = healthPlanService.regenerateSection(familyId, section, feedback, planJsonStr);
|
|
|
|
|
+ return Result.success(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Operation(summary = "保存/更新健康方案(支持结构化 planJson)")
|
|
|
@PostMapping("/save")
|
|
@PostMapping("/save")
|
|
|
public Result<Long> save(@RequestBody Map<String, Object> params,
|
|
public Result<Long> save(@RequestBody Map<String, Object> params,
|
|
|
@RequestAttribute("userId") Long userId,
|
|
@RequestAttribute("userId") Long userId,
|
|
@@ -43,21 +60,39 @@ public class HealthPlanController {
|
|
|
String dimensions = (String) params.get("dimensions");
|
|
String dimensions = (String) params.get("dimensions");
|
|
|
String goal = (String) params.get("goal");
|
|
String goal = (String) params.get("goal");
|
|
|
String planContent = (String) params.get("planContent");
|
|
String planContent = (String) params.get("planContent");
|
|
|
|
|
+ String planJson = (String) params.get("planJson");
|
|
|
String memberName = (String) params.get("memberName");
|
|
String memberName = (String) params.get("memberName");
|
|
|
- if (familyId == null || dimensions == null || goal == null || planContent == null) {
|
|
|
|
|
- return Result.error("familyId, dimensions, goal, planContent不能为空");
|
|
|
|
|
|
|
+ Long planId = ParamUtils.getLong(params.get("planId"));
|
|
|
|
|
+ String status = (String) params.get("status");
|
|
|
|
|
+
|
|
|
|
|
+ if (familyId == null || dimensions == null || goal == null) {
|
|
|
|
|
+ return Result.error("familyId, dimensions, goal不能为空");
|
|
|
}
|
|
}
|
|
|
HealthPlan plan = new HealthPlan();
|
|
HealthPlan plan = new HealthPlan();
|
|
|
|
|
+ plan.setId(planId);
|
|
|
plan.setFamilyId(familyId);
|
|
plan.setFamilyId(familyId);
|
|
|
plan.setMemberIds(memberIds != null ? memberIds : "");
|
|
plan.setMemberIds(memberIds != null ? memberIds : "");
|
|
|
plan.setDimensions(dimensions);
|
|
plan.setDimensions(dimensions);
|
|
|
plan.setGoal(goal);
|
|
plan.setGoal(goal);
|
|
|
plan.setPlanContent(planContent);
|
|
plan.setPlanContent(planContent);
|
|
|
|
|
+ plan.setPlanJson(planJson);
|
|
|
plan.setMemberName(memberName);
|
|
plan.setMemberName(memberName);
|
|
|
|
|
+ if (status != null) plan.setStatus(status);
|
|
|
Long id = healthPlanService.savePlan(plan);
|
|
Long id = healthPlanService.savePlan(plan);
|
|
|
return Result.success(id);
|
|
return Result.success(id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Operation(summary = "确认方案(提交后不可再编辑)")
|
|
|
|
|
+ @PostMapping("/confirm")
|
|
|
|
|
+ public Result<Long> confirm(@RequestBody Map<String, Object> params,
|
|
|
|
|
+ @RequestAttribute("userId") Long userId,
|
|
|
|
|
+ @RequestAttribute(value = "familyId", required = false) Long familyId) {
|
|
|
|
|
+ Long planId = ParamUtils.getLong(params.get("planId"));
|
|
|
|
|
+ if (planId == null) return Result.error("planId不能为空");
|
|
|
|
|
+ Long id = healthPlanService.confirmPlan(planId);
|
|
|
|
|
+ return Result.success(id);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Operation(summary = "查询历史方案列表")
|
|
@Operation(summary = "查询历史方案列表")
|
|
|
@PostMapping("/list")
|
|
@PostMapping("/list")
|
|
|
public Result<List<HealthPlan>> list(@RequestBody Map<String, Object> params,
|
|
public Result<List<HealthPlan>> list(@RequestBody Map<String, Object> params,
|
|
@@ -77,4 +112,4 @@ public class HealthPlanController {
|
|
|
if (plan == null) return Result.error("方案不存在");
|
|
if (plan == null) return Result.error("方案不存在");
|
|
|
return Result.success(plan);
|
|
return Result.success(plan);
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
|
|
+}
|