docs: update plans and agent instructions
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
96
docs/plan.md
96
docs/plan.md
@@ -1,76 +1,88 @@
|
||||
# Implementation Plan: Payment Flow Rules & Verification
|
||||
# Implementation Plan: backend-test-coverage
|
||||
|
||||
**Branch**: `main` | **Date**: 2026-02-03 | **Spec**: `docs/seed_verification.md`
|
||||
**Input**: 统一支付流程规则,完善前后端联调与验证路径。
|
||||
**Branch**: `[test-coverage-t3-t4]` | **Date**: 2026-02-04 | **Spec**: N/A
|
||||
**Input**: Continuation of test coverage tasks (T3/T4) from prior session; no feature spec.
|
||||
|
||||
## Summary
|
||||
|
||||
明确支付流程的接口契约与前端交互(创建订单→支付→状态查询),补齐规则并制定验证步骤,确保页面交互与数据库状态一致。
|
||||
Complete backend service test coverage for content access policies (T3) and superadmin write operations (T4), ensuring existing behavior is validated without altering production logic.
|
||||
|
||||
## Technical Context
|
||||
|
||||
**Language/Version**: Go 1.22, Vue 3 (Vite)
|
||||
**Primary Dependencies**: Fiber, Vite, existing `/orders`/`/pay`/`/status` APIs
|
||||
**Storage**: PostgreSQL
|
||||
**Testing**: 页面自动化(MCP)+ 手动校验
|
||||
**Target Platform**: local/staging
|
||||
**Project Type**: Web application
|
||||
**Performance Goals**: N/A
|
||||
**Constraints**: 不改生成文件;遵循 `backend/llm.txt`
|
||||
**Scale/Scope**: 支付流程规范与验证
|
||||
**Language/Version**: Go 1.x (project standard)
|
||||
**Primary Dependencies**: Fiber, GORM-Gen, Testify
|
||||
**Storage**: PostgreSQL (via GORM)
|
||||
**Testing**: `go test` (service tests under `backend/app/services/*_test.go`)
|
||||
**Target Platform**: Linux server
|
||||
**Project Type**: Web application (frontend + backend)
|
||||
**Performance Goals**: N/A (test-only changes)
|
||||
**Constraints**: No changes to generated files; keep tests aligned with existing service patterns
|
||||
**Scale/Scope**: Backend service tests only (no frontend scope)
|
||||
|
||||
## Constitution Check
|
||||
|
||||
- 仅文档/规则梳理,若后续改代码需遵守生成文件不可直改规则。
|
||||
- Follow `backend/llm.txt` for backend conventions.
|
||||
- Keep controllers thin; service tests only (no controller edits).
|
||||
- Avoid editing generated files (`routes.gen.go`, `docs.go`).
|
||||
- Run `go test` for impacted service packages.
|
||||
|
||||
## Project Structure
|
||||
|
||||
### Documentation (this feature)
|
||||
|
||||
```text
|
||||
docs/
|
||||
├── plan.md # 本计划
|
||||
├── seed_verification.md # 页面→操作→数据验证清单
|
||||
└── plans/ # 归档目录
|
||||
frontend/portal/src/views/order/ # Checkout/Payment
|
||||
backend/app/http/v1/transaction.go # orders/pay/status/webhook
|
||||
specs/[###-feature]/
|
||||
└── (not used for this task)
|
||||
```
|
||||
|
||||
**Structure Decision**: 在现有前后端目录内完善支付契约说明与测试步骤,不新增结构。
|
||||
### Source Code (repository root)
|
||||
|
||||
```text
|
||||
backend/
|
||||
├── app/
|
||||
│ ├── services/
|
||||
│ │ ├── content_test.go
|
||||
│ │ └── super_test.go
|
||||
└── app/http/v1/dto/
|
||||
└── content.go
|
||||
```
|
||||
|
||||
**Structure Decision**: Web application structure; scope is backend service tests in `backend/app/services`.
|
||||
|
||||
## Plan Phases
|
||||
|
||||
### Phase 1: 规则梳理
|
||||
- 明确 `/orders` 创建所需字段与返回字段(价格、content_title、status、id)。
|
||||
- 明确 `/orders/:id/pay` 入参与预期状态变更;`/orders/:id/status` 响应格式。
|
||||
|
||||
### Phase 2: 前后端对齐点
|
||||
- 若后端缺字段/逻辑,提出对齐要求;前端 Checkout/Payment 显示金额、商品名、状态并可发起 pay/模拟成功。
|
||||
|
||||
### Phase 3: 验证与记录
|
||||
- 执行创建→支付→状态流;校验页面与 DB (`orders`, `order_items`, `content_access`) 一致;记录缺口(若 pay 未实现则记为待补)。
|
||||
1. Inspect DTO definitions used by content tests to fix T3 assertions.
|
||||
2. Implement remaining content access policy tests (T3) and verify via `go test`.
|
||||
3. Implement superadmin write operation tests (T4) and verify via `go test`.
|
||||
|
||||
## Tasks
|
||||
|
||||
- [ ] T001 梳理 `/orders` 创建与返回字段(content_id, price_amount, id/status)
|
||||
- [ ] T002 梳理 `/orders/:id/pay` 入参与成功/失败状态定义
|
||||
- [ ] T003 梳理 `/orders/:id/status` 响应字段(status, amount_paid/original, content_title)
|
||||
- [ ] T010 前端显示与调用对齐(Checkout 显示金额/标题,Payment 调用 pay+轮询)
|
||||
- [ ] T020 验证创建→支付→状态→订单详情链路;记录 DB 状态变化
|
||||
- [ ] T030 汇总缺口(如 pay 未实现、字段缺失),更新 `docs/seed_verification.md`
|
||||
1. Read `backend/app/http/v1/dto/content.go` and update T3 test assertions to match actual DTO fields.
|
||||
2. Extend `backend/app/services/content_test.go` with missing content access policy cases and run targeted tests.
|
||||
3. Extend `backend/app/services/super_test.go` for superadmin write operations; run service test suite.
|
||||
4. Verify all added tests pass without modifying production logic.
|
||||
|
||||
## Dependencies
|
||||
|
||||
- Phase 1 → Phase 2 → Phase 3
|
||||
- Task 1 must complete before Task 2 (DTO fields drive assertions).
|
||||
- Task 2 should complete before Task 3 to isolate failures.
|
||||
|
||||
## Acceptance Criteria
|
||||
|
||||
- 支付接口契约(字段/状态)明确并记录。
|
||||
- 前端 Checkout/Payment 能显示金额/商品名并调用 pay+轮询;若后端未实现,缺口已记录。
|
||||
- 手动/自动化验证创建→支付→状态→订单详情链路,DB 状态与页面一致。
|
||||
- `backend/app/services/content_test.go` has passing T3 coverage for unauthenticated access constraints.
|
||||
- `backend/app/services/super_test.go` includes T4 coverage for create-tenant side effects and superadmin write operations.
|
||||
- `go test ./backend/app/services/...` passes.
|
||||
- No generated files modified.
|
||||
|
||||
## Risks
|
||||
|
||||
- 后端 pay/status 未实现或字段缺失导致无法完成闭环(需记录缺口)。
|
||||
- DTO field changes may require adjusting test assertions; mitigate by verifying struct definitions.
|
||||
- Service behavior may differ from assumptions in prior session; mitigate by aligning with existing tests.
|
||||
|
||||
## Complexity Tracking
|
||||
|
||||
无。
|
||||
> **Fill ONLY if Constitution Check has violations that must be justified**
|
||||
|
||||
| Violation | Why Needed | Simpler Alternative Rejected Because |
|
||||
|-----------|------------|-------------------------------------|
|
||||
| N/A | N/A | N/A |
|
||||
|
||||
Reference in New Issue
Block a user