feat: extend staging seed data

This commit is contained in:
2026-01-26 09:04:29 +08:00
parent 9607b914c9
commit 619e17fc15
3 changed files with 252 additions and 13 deletions

View File

@@ -0,0 +1,92 @@
# Implementation Plan: Staging Seed Data
**Branch**: `main` | **Date**: 2026-01-26 | **Spec**: `docs/staging_smoke_test.md`
**Input**: staging 冒烟测试需要快速准备基础数据。
**Note**: 本计划遵循 `docs/templates/plan-template.md`
## Summary
扩展 Go seed 命令,生成 staging 冒烟测试所需的最小数据集(租户、用户、超管、内容、订单、优惠券、通知等),确保前后台关键页面可快速验证。
## Technical Context
**Language/Version**: Go 1.22
**Primary Dependencies**: Fiber, GORM-Gen
**Storage**: PostgreSQL + Redis
**Testing**: `go test ./...`
**Target Platform**: Linux server (staging)
**Project Type**: Web application (backend + frontend)
**Performance Goals**: N/A
**Constraints**: 不修改生成文件Service/Controller 规范保持不变
**Scale/Scope**: 最小可用冒烟数据
## Constitution Check
- 遵循 `backend/llm.txt` 规则(不改生成文件、中文注释、服务层规范)。
- seed 逻辑仅在 `backend/app/commands/seed/seed.go` 修改。
## Project Structure
### Documentation (this feature)
```text
docs/
└── plan.md
```
### Source Code (repository root)
```text
backend/
└── app/commands/seed/seed.go
```
**Structure Decision**: 使用现有 seed 命令注入 staging 数据。
## Plan Phases
### Phase 1: 数据范围确认
- 明确需覆盖的冒烟用例与最小数据集。
### Phase 2: Seed 扩展实现
- 增加超管用户、租户成员、订单与内容访问等基础数据。
- 确保幂等运行(重复执行不报错)。
### Phase 3: 文档与验证
- 记录 seed 运行方式与输出数据说明。
## Tasks
**Format**: `[ID] [P?] [Story] Description`
### Phase 1: Foundational
- [x] T001 [US0] 明确冒烟必需数据项(用户/租户/内容/订单/通知)
### Phase 2: Seed 扩展
- [x] T010 [US1] 创建超管用户与角色
- [x] T011 [US1] 创建租户成员与权限关系
- [x] T012 [US1] 创建订单、订单项、内容访问记录
- [x] T013 [US1] 创建通知模板/系统通知
### Phase 3: Docs
- [x] T020 [US2] 更新 seed 说明文档/输出示例
## Dependencies
- Phase 1 → Phase 2 → Phase 3。
## Acceptance Criteria
- `go run ./backend/main.go seed` 可成功生成数据。
- seed 后 staging 冒烟清单主要页面可打开并有数据展示。
- 重复运行 seed 不产生致命错误。
## Risks
- 真实 staging 数据冲突(唯一索引)。
- 订单/访问数据缺失导致部分页面空白。
## Complexity Tracking
无。

View File

@@ -9,6 +9,7 @@
- Test user credentials (OTP or seeded user)
- Superadmin credentials (role: `super_admin`)
- Storage bucket configured for staging
- Seed data loaded via `go run ./backend/main.go seed`
## Portal (Tenant)
@@ -94,6 +95,13 @@
10. **Health**
- Check health endpoints (service/storage status).
## Seed Data Notes
- Tenant: seed creates one tenant with code like `meipai_<rand>`.
- Users: `creator` (creator role), `test` (regular user), `superadmin` (super admin).
- Orders: one paid order with library access to first content.
- Notifications, templates, audit log, system config, content report included.
## Pass/Fail Criteria
- All pages load without 5xx/4xx errors (except expected auth errors).