spark-server/.cursor/rules/module-layers.mdc
zhr 8870c59e2d docs(cursor): 优化 spark-im-v3 skill 与 Agent 说明
新增 mysql.md(t_ 表名与 migrate 流程),补全 /v1/music·square 与 admin 路由说明;description 与 AGENTS/rules 对齐 make test→lint 与 deploy 门禁,减少与 verify-before-done 重复。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-24 11:09:15 +08:00

20 lines
843 B
Plaintext

---
description: Module layering — entity, model, logic. One GORM file per table.
globs: internal/module/**/*.go
alwaysApply: false
---
# Module layers
Each business module under `internal/module/{biz}` is three packages:
| Layer | Path | Owns |
|-------|------|------|
| entity | `{biz}/entity` | Domain structs, message payload types, no I/O |
| model | `{biz}/model` | One Go file per MySQL table (`TableName()` → `t_*`, GORM + COMMENT tags), Redis adapters |
| logic | `{biz}/logic` | One file per **function** (profile, login, send, inbox sync). Not one file per table. |
`logic` must not import `model`. Wire implementations in `internal/bootstrap`. Auth has no tables (entity + logic only).
Message `content` is serialized JSON **bytes** in a BLOB. Never persist a raw string. Media is an object-storage key, never file bytes.