Files
JARVIS/development-doc/plan/today-status-update/phase-ts-2-task-api-and-schedule-aggregation.md

107 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Phase TS-2Task API 与 Schedule 聚合扩展
日期2026-04-08
状态:待实施
---
## 1. 阶段目标
扩展后端 Task API 与 Schedule Center 聚合,让前端可以真实创建、读取、编辑、分配任务,并让 Today Status 直接消费真实聚合视图。
---
## 2. 详细任务
### 2.1 扩展 Task API
**文件**
- `backend/app/routers/task.py`
- `backend/app/schemas/task.py`
- `frontend/src/api/task.ts`
建议接口:
- `GET /api/tasks`
- `POST /api/tasks`
- `GET /api/tasks/{task_id}`
- `PATCH /api/tasks/{task_id}`
- `DELETE /api/tasks/{task_id}`
- `POST /api/tasks/{task_id}/subtasks`
- `PATCH /api/tasks/{task_id}/subtasks/{subtask_id}`
- `DELETE /api/tasks/{task_id}/subtasks/{subtask_id}`
- `POST /api/tasks/{task_id}/subtasks/reorder`
- `POST /api/tasks/{task_id}/dispatch`
- `POST /api/tasks/{task_id}/subtasks/{subtask_id}/dispatch`
### 2.2 Task detail 输出
`GET /api/tasks/{task_id}` 建议返回:
- task 基础字段
- subtasks
- history
- dispatch 摘要
### 2.3 扩展 Schedule Center 聚合
**文件**
- `backend/app/routers/schedule_center.py`
- `backend/app/schemas/schedule_center.py`
- `frontend/src/api/scheduleCenter.ts`
建议在 `ScheduleCenterDateOut` 增加:
- `focus_tasks`
- `quadrants`
- `commander_summary`
### 2.4 前端 API 同步
`frontend/src/api/task.ts` 需要扩展:
- detail 方法
- subtask CRUD / reorder
- dispatch 方法
`frontend/src/api/scheduleCenter.ts` 需要扩展:
- `focus_tasks`
- `quadrants`
- `commander_summary` 类型
---
## 3. 设计原则
1. **复用现有 task router不另开 taskV2**
2. **复用现有 schedule-center 聚合,不另开第二套 today-status API**
3. **dispatch 是显式动作,不隐含在普通 update 里**
---
## 4. 核心文件清单
| 文件 | 操作 | 说明 |
|------|------|------|
| `backend/app/routers/task.py` | 修改 | 扩展任务、子任务、派发 API |
| `backend/app/schemas/task.py` | 修改 | detail/subtask/dispatch schema |
| `backend/app/routers/schedule_center.py` | 修改 | 扩展今日聚合 |
| `backend/app/schemas/schedule_center.py` | 修改 | 扩展 response model |
| `frontend/src/api/task.ts` | 修改 | 前端任务 API 能力补齐 |
| `frontend/src/api/scheduleCenter.ts` | 修改 | 前端聚合类型补齐 |
---
## 5. 验收标准
- [ ] Task detail 能返回 subtasks / history / dispatch 信息
- [ ] 子任务 CRUD / reorder API 设计明确
- [ ] dispatch API 明确独立
- [ ] `schedule-center/date` 可直接供 Today Status 使用
- [ ] 前端 API 类型已同步
---
## 6. 依赖关系
```text
依赖Phase TS-1
输出给Phase TS-3 / TS-4 / TS-5
```