Files
digital-psychology/.ai/architecture/go-services.md
T
jackyu66gitandCursor 879bf70cb7
ci / h5 (push) Canceled after 0s
ci / api (push) Canceled after 0s
ci / ess-docs (push) Canceled after 0s
feat(ECR-006): 落地运营后台 Phase A(admin API + admin-h5)
新增独立鉴权的 /api/v1/admin 与 Vue 控制台;会员授予与审计同事务,并补集成/单测。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-06 18:35:53 +08:00

52 lines
2.5 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.
# Go 服务边界(冻结)
单二进制 `apps/api`;按包拆分,**禁止**跨层:Handler → Service → Repository。
详见 [../architecture.md](../architecture.md)。
---
## Packages under `internal/service/`
| Package | 职责 | P1 | 实现态(2026-08 |
|---|---|---|---|
| `user` | 注册/游客升级/Session | Yes | 多在 profile/auth 路径;无独立包名时勿重复造轮 |
| `profile` | 个人档案 CRUD、切换 | Yes | `service/profile` |
| `portrait` | 生成个人画像 → GrowthReport | Yes | 计算在 `internal/portrait`;用例经 report/handler 路径 |
| `scale` | 探索测试定义与计分 | Yes | `service/scale` + `internal/scale` |
| `relation` | RelationInsight | Yes **必做** | `service/relation` + `internal/relation` |
| `report` | GrowthReport 读取 + **权益裁剪** | Yes | `service/report` |
| `ask` | Thread/MessageP1 规则引擎 + 额度 | YesDemo | `service/ask` + `internal/ask` |
| `companion` | SolarTerm 读、Mood 写 | Shell | `service/companion` |
| `membership` | 成长会员状态与额度 | Yes | `service/membership`ECR-001 Phase C 已从 report 抽出) |
| `order` | Order + pay-mock + DeepAccess 发放 | Yes | 用例在 `service/membership`(同 Phase C;未单独拆包) |
| `imagecard` | 意象卡片 | P2 | `service/imagecard` |
| `admin` | 运营后台鉴权与运维用例 | Ops-A | `service/admin`ECR-006 |
### Engine vs Service
| Kind | Path | Can | Cannot |
|---|---|---|---|
| Engine | `internal/{portrait,relation,star,ask,scale,rhythm,…}` | 纯计算 / 组装报告结构 | 引用 `gin.Context`;做权益解锁 |
| Service | `internal/service/*` | 用例编排、鉴权后业务、调 repo/engine | SQL 直写;跳过归属校验 |
`internal/handler/`:每域一组 handler,只做 bind/validate/调用 service。
`internal/repository/`SQL;无 business unlock 规则(规则在 service/report + membership)。
星座周期展望引擎包:`internal/star/outlook`(原 `fortune`ECR-002)。对外 JSON 仅 `outlook` / `outlook_detail`;周期提示字段为 `boost`ECR-003 已移除 `fortune`/`lucky` 兼容键)。
---
## 跨域规则
- **权益判定**只在 `report` / `ask` / `membership` service,不在 handler、不在 H5。
- `portrait``relation``growth_reports`;读一律走 `report.Get`(带裁剪)。
- `ask` 强制校验 `profile` 归属当前 user。
---
## 禁止
- 新建 `decode` / `match` / `unlock` / `fortune` 包名
- Handler 直连 DB
- 在 JSON 字段名使用 `luck` / `fortune` / `ji_xiong`