thread-master/docs/product/scout-topic-quality/tasks/T034-run-usecase-api.md

60 lines
1.8 KiB
Markdown
Raw Permalink 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.

# T034 — Run usecase 與 API logic
> Status: `done`
> Milestone: `M3`
> Est. change: `~180 lines`
## Goal
完成後,會員可透過真 usecase 分頁列出自己的 runsresults 並刪除終態 run。
## Depends on
- T033
## Inputs
- 讀取 / 依賴:
- 檔案:`apps/backend/internal/module/scout/usecase/service.go`、`internal/logic/scout/*run*_logic.go`
- 既有能力 / APIRun repository、UID middleware、response.Biz、converters
- Spec 段落§4 流程 DF、§5.1
## Outputs
### 程式變更(預期路徑)
| 路徑 | 動作 | 說明 |
|------|------|------|
| `apps/backend/internal/module/scout/usecase/runs.go` | add | 實作 ListRuns、ListRunPosts、RemoveRun 與 page clamp。 |
| `apps/backend/internal/logic/scout/list_scout_runs_logic.go` | edit | 以真 usecase 取代 T022 的 503。 |
| `apps/backend/internal/logic/scout/list_scout_run_posts_logic.go` | edit | 回 runlistpagination。 |
| `apps/backend/internal/logic/scout/remove_scout_run_logic.go` | edit | 終態刪除running 回 409。 |
| `apps/backend/internal/logic/scout/run_logic_test.go` | add | 覆蓋 auth、owner、pagination 與 conflict。 |
### 行為變更
- 非 owner 資源對外視為 404不得洩漏是否存在。
### API / 契約(若有)
- 成功 envelope 由既有 gateway 統一包裝data 不包含 owner UID。
## Out of scope
- 不建立 run、不執行搜尋或 job。
## Acceptance
- [x] 新端點不再有成功空資料或暫時 503。
- [x] 指令:
```bash
cd apps/backend && go test ./internal/module/scout/... ./internal/logic/scout/... -count=1
```
驗收結果Run usecase 與三個 API logic 已接上 owner-scoped repository列表、結果分頁、終態刪除及授權跨 owner衝突測試通過。
## Notes
刪除 run 不刪 homework單 post 刪除後更新 run counts。