|
|
@@ -0,0 +1,62 @@
|
|
|
+package com.etotem.cfc.controller.admin;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.etotem.cfc.common.Result;
|
|
|
+import com.etotem.cfc.entity.HealthPlan;
|
|
|
+import com.etotem.cfc.entity.Task;
|
|
|
+import com.etotem.cfc.service.HealthPlanService;
|
|
|
+import com.etotem.cfc.util.ParamUtils;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Tag(name = "管理端-健康方案", description = "跨家庭健康方案列表与详情")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/api/admin/health-plan")
|
|
|
+public class AdminHealthPlanController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private HealthPlanService healthPlanService;
|
|
|
+
|
|
|
+ @Operation(summary = "健康方案分页列表(按成员展示)")
|
|
|
+ @PostMapping("/list")
|
|
|
+ public Result<Page<HealthPlan>> list(@RequestBody Map<String, Object> params,
|
|
|
+ @RequestAttribute("role") String role) {
|
|
|
+ if (!"admin".equals(role) && !"teacher".equals(role) && !"butler".equals(role)
|
|
|
+ && !"nutritionist".equals(role) && !"operator".equals(role)) {
|
|
|
+ return Result.error("无权限");
|
|
|
+ }
|
|
|
+ int page = params.get("page") != null ? ((Number) params.get("page")).intValue() : 1;
|
|
|
+ int size = params.get("size") != null ? ((Number) params.get("size")).intValue() : 20;
|
|
|
+ Long familyId = ParamUtils.getLong(params.get("familyId"));
|
|
|
+ String status = params.get("status") != null ? params.get("status").toString() : null;
|
|
|
+ String keyword = params.get("keyword") != null ? params.get("keyword").toString() : null;
|
|
|
+ Page<HealthPlan> result = healthPlanService.adminListPlans(familyId, status, keyword, page, size);
|
|
|
+ return Result.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Operation(summary = "健康方案详情(含分解任务)")
|
|
|
+ @PostMapping("/detail")
|
|
|
+ public Result<HealthPlan> detail(@RequestBody Map<String, Object> params,
|
|
|
+ @RequestAttribute("role") String role) {
|
|
|
+ if (!"admin".equals(role) && !"teacher".equals(role) && !"butler".equals(role)
|
|
|
+ && !"nutritionist".equals(role) && !"operator".equals(role)) {
|
|
|
+ return Result.error("无权限");
|
|
|
+ }
|
|
|
+ Long planId = ParamUtils.getLong(params.get("planId"));
|
|
|
+ if (planId == null) {
|
|
|
+ return Result.error("planId不能为空");
|
|
|
+ }
|
|
|
+ HealthPlan plan = healthPlanService.getPlanDetail(planId);
|
|
|
+ if (plan == null) {
|
|
|
+ return Result.error("方案不存在");
|
|
|
+ }
|
|
|
+ List<Task> tasks = healthPlanService.getPlanTasks(planId);
|
|
|
+ plan.setTasks(tasks);
|
|
|
+ return Result.success(plan);
|
|
|
+ }
|
|
|
+}
|