Explorar o código

feat(S-cfc-374): plan.task.list 方案维度任务清单(SC-P-47)——GrowthPlanService.planTaskList(Long) 按 planId 锚定实时查 tasks(source_type='plan' AND source_id=planId),区别于 getProgress 聚合 VO;GrowthPlanController.planTasks 暴露 POST /api/growth/plan/tasks(planId缺失→planId不能为空,方案不存在→方案不存在;无缓存,任务增删与方案同步)。PlanTaskListContractTest 11/11 红转绿

zxyj-langgraph hai 5 días
pai
achega
0472da1196

+ 11 - 0
cfc-backend/src/main/java/com/etotem/cfc/controller/growth/GrowthPlanController.java

@@ -2,6 +2,7 @@ package com.etotem.cfc.controller.growth;
 
 import com.etotem.cfc.common.Result;
 import com.etotem.cfc.entity.GrowthPlan;
+import com.etotem.cfc.entity.Task;
 import com.etotem.cfc.service.GrowthPlanService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -84,6 +85,16 @@ public class GrowthPlanController {
         return Result.success(plan);
     }
 
+    @Operation(summary = "查询成长方案任务清单(SC-P-47 查看方案下任务列表,能力键 plan.task.list)")
+    @PostMapping("/tasks")
+    public Result<List<Task>> planTasks(@RequestBody Map<String, Object> params) {
+        Long planId = ParamUtils.getLong(params.get("planId"));
+        if (planId == null) return Result.error("planId不能为空");
+        GrowthPlan plan = growthPlanService.getById(planId);
+        if (plan == null) return Result.error("方案不存在");
+        return Result.success(growthPlanService.planTaskList(planId));
+    }
+
     @Operation(summary = "更新成长方案")
     @PostMapping("/update")
     public Result<Boolean> updatePlan(@RequestBody Map<String, Object> body) {

+ 29 - 0
cfc-backend/src/main/java/com/etotem/cfc/service/GrowthPlanService.java

@@ -70,6 +70,35 @@ public class GrowthPlanService {
         return vo;
     }
 
+    /**
+     * 方案维度任务清单(SC-P-47 查看方案下任务列表,能力键 plan.task.list)。
+     *
+     * <p>口径:按 planId 锚定,返回 tasks.source_type='plan' AND source_id=planId 的全部任务明细
+     * (含 status;进度型任务的 progress/todayDone 由任务侧查询回填)。
+     * 区别于 task.* 通用任务视图(按 memberId 锚定);与 getProgress(聚合=进度卡)分工:
+     * 聚合统计看进度,本方法承载明细清单视图。</p>
+     *
+     * <p>任务增删与方案同步:每次调用实时查询任务表,不做缓存,保证列表与最新任务集一致。</p>
+     *
+     * @param planId 成长方案ID(锚点)
+     * @return 方案下任务明细列表;planId 为空或方案不存在时返回空列表(安全默认,不抛 NPE)
+     */
+    public List<Task> planTaskList(Long planId) {
+        if (planId == null) {
+            return new ArrayList<>();
+        }
+        GrowthPlan plan = growthPlanMapper.selectById(planId);
+        if (plan == null) {
+            return new ArrayList<>();
+        }
+        LambdaQueryWrapper<Task> wrapper = new LambdaQueryWrapper<Task>()
+                .eq(Task::getSourceType, PLAN_TASK_SOURCE_TYPE)
+                .eq(Task::getSourceId, planId)
+                .orderByAsc(Task::getId);
+        List<Task> tasks = taskMapper.selectList(wrapper);
+        return tasks != null ? tasks : new ArrayList<>();
+    }
+
     public GrowthPlan createPlan(GrowthPlan plan) {
         if (plan.getStatus() == null) {
             plan.setStatus("active");

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
docs/superpowers/PROJECT-OVERVIEW.md


+ 1 - 0
docs/superpowers/api/API_REFERENCE.md

@@ -582,6 +582,7 @@ find cfc-backend/src/main/java -name "*XxxService.java" -o -name "*XxxController
 | `POST /api/growth/plan/child/{memberId}` | 成员计划 |
 | `POST /api/growth/plan/{id}` | 计划详情 |
 | `POST /api/growth/plan/{id}/review` | 审核计划 |
+| `POST /api/growth/plan/tasks` | 方案任务清单(SC-P-47 `plan.task.list`:按 planId 锚定,返回 `source_type='plan' AND source_id=planId` 的任务明细,含状态/进度;`planId` 缺失→`planId不能为空`,方案不存在→`方案不存在`;任务增删与方案实时同步) |
 
 ### 4.7 健康打卡(`/api/health/*`, `/api/daily/checkin`, `/api/mind/checkin`)
 

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio