Files
digital-psychology/docs/BACKEND_DESIGN/BD-2026-013-scale-bank-explore.md
T
jackyu66gitandCursor 89756f65b4 feat(ECR-012–016): 合规、题库、时辰刷新、头像、MBTI OEJTS 与埋点
落地输入合规、探索题库、报告日/时辰刷新、账号头像、OEJTS 量表,并补齐 H5 埋点与 Admin 漏斗;同步 ESS 工件、切至自建 Git、清理 GitHub Actions。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-13 01:27:58 +08:00

67 lines
1.8 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.
# BD-2026-013 — Curated scale bank (explore)
Status: Approved
**ECR:** ECR-013
**Date:** 2026-08-13
**Change Level:** L2
**Risk:** Low–Med(题量大 · 文案非诊断)
## Backend Change Boundary
### In
- Package `internal/scalebank`embed `curated.json` · Catalog/Category/Get/ScoreSum/QuestionID
- `service/scale`bank slug Get/Submit/LatestResult`EnsurePublished` stub 行
- `handler/scale``/scale-bank/*`
- `repository.ScaleRepo.EnsurePublished`
### Out
- 新业务表存题目全文(题目仅 embed)· 临床类 · Admin 题库 CMS
## Module
| Module | Change |
|--------|--------|
| scalebank | embed A 集 · 稳定 QuestionID |
| scale service | bank 分支计分 BuildResult + disclaimer |
| scale handler | catalog / category |
| OpenAPI | 上述路径 |
## Data flow
```text
H5 /explore → GET scale-bank/catalog
H5 /explore/bank/:key → GET scale-bank/categories/:key
H5 /scales/:slug → Get(bank|db) → optional GET result → POST result
Submit bank → EnsurePublished → ScoreSum → BuildResult → SaveResult
```
## API
| Method | Path | Notes |
|--------|------|-------|
| GET | `/api/v1/scale-bank/catalog` | featured + categories |
| GET | `/api/v1/scale-bank/categories/:key` | category + items |
| GET/POST | `/api/v1/scales/:slug` / `.../result` | bank slug 同契约 |
## Migration
NO`EnsurePublished` upsert `scales` 元数据行;题目不入库)
## Test
- unit`scalebank` catalog/featured icons unique
- integration`TestScaleBankResultRoundtrip`sm1
- H5ScalePage latest result(含 bank slug
## Rollback
- 下线路由 + 回退 Explore UI;已写 `scale_results` 可保留
## Failure
- 未知 category → 40402
- 无结果 → 40411
- 无 Self profile → 提交 400