From bdf20fb0c68a4e3fbabb76feb5c6abe48ec988af Mon Sep 17 00:00:00 2001 From: Rogee Date: Mon, 29 Dec 2025 15:44:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E7=BA=A6=E5=AE=9A=EF=BC=8C=E8=A6=81=E6=B1=82?= =?UTF-8?q?=E6=95=B0=E5=AD=97ID=E8=B7=AF=E5=BE=84=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E5=9C=A8@Router=E6=B3=A8=E8=A7=A3=E4=B8=AD=E6=98=BE=E5=BC=8F?= =?UTF-8?q?=E5=A3=B0=E6=98=8E=E7=B1=BB=E5=9E=8B=E4=BB=A5=E7=A1=AE=E4=BF=9D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/llm.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/llm.txt b/backend/llm.txt index c9f13f0..b84d949 100644 --- a/backend/llm.txt +++ b/backend/llm.txt @@ -30,7 +30,7 @@ This file condenses `backend/docs/dev/http_api.md` + `backend/docs/dev/model.md` - DO NOT manually write route declarations (only `atomctl gen route`). - DO keep Swagger annotations consistent with actual Fiber route paths (including `:param`). - MUST: route path parameter placeholders MUST be `camelCase` (e.g. `:tenantCode`), never `snake_case` (e.g. `:tenant_code`). -- MUST: for numeric ID path params (`int/int64` like `tenantID/userID/orderID`), prefer Fiber typed params `:tenantID` to avoid conflicts with static subpaths (e.g. `/orders/statistics`) and reduce ambiguous routing. +- MUST: for numeric ID path params (`int/int64` like `tenantID/userID/orderID/id`), explicit declaration `:param` is REQUIRED in `@Router` annotation to ensure proper route matching and constraints (e.g. `@Router /v1/users/:id [get]`). - MUST: when importing another HTTP module's `dto` package, the import alias MUST be `_dto` (e.g. `tenant_dto`), not `dto` (e.g. `tenantdto`). - MUST: when creating/generating Go `struct` definitions (DTOs/requests/responses/etc.), add detailed per-field comments describing meaning, usage scenario, and validation/usage rules (do not rely on “self-explanatory” names). - MUST: business code comments MUST be written in Chinese (中文注释), to keep review/maintenance consistent across the team. @@ -250,7 +250,7 @@ In this case: - `backend/app/events/subscribers/.go`(subscriber:实现 `contracts.EventHandler`,负责 `Topic()` + `Handler(...)`) - 生成后:按项目约定运行一次 `atomctl gen provider`(用于刷新 DI/provider 生成文件)。 -### Topic约定 +### Topic 约定 - 统一在 `backend/app/events/topics.go` 维护 topic 常量,避免散落在各处形成“字符串协议”。 - topic 字符串建议使用稳定前缀(例如 `event:`),并使用 `snake_case` 命名。 @@ -299,7 +299,7 @@ Common types: - `Kind` 建议与业务枚举/事件类型对齐,便于 SQL/报表按 `kind` 过滤。 - `Data` 写入对应 payload 的 JSON(payload 可以是多个不同 struct)。 - 读取时: - - 先 `snap := model.Snapshot.Data()`,再 `switch snap.Kind` 选择对应 payload结构去 `json.Unmarshal(snap.Data, &payload)`。 + - 先 `snap := model.Snapshot.Data()`,再 `switch snap.Kind` 选择对应 payload 结构去 `json.Unmarshal(snap.Data, &payload)`。 - 兼容历史数据(旧 JSON 没有 kind/data)时,`UnmarshalJSON` 可以将其标记为 `legacy` 并把原始 JSON 放入 `Data`,避免线上存量读取失败。 --- @@ -464,4 +464,4 @@ func (s *XxxTestSuite) Test_Method() { So(got, ShouldBeNil) }) } -``` +``` \ No newline at end of file