feat(llm): 更新开发规则,添加关于DTO和分页响应的JSON标签要求
This commit is contained in:
@@ -8,6 +8,9 @@ This file condenses `backend/docs/dev/http_api.md` + `backend/docs/dev/model.md`
|
||||
|
||||
- DO follow existing module layout under `backend/app/http/<module>/`.
|
||||
- MUST: HTTP module folder name MUST be `snake_case` (e.g. `tenant_public`), not `camelCase`/`mixedCase`.
|
||||
- MUST: JSON tags in DTOs and all response/request structs MUST use `snake_case` (e.g., `json:"user_id"`), never `camelCase` (e.g., `json:"userId"`).
|
||||
- MUST: Paginated list endpoints MUST return `*requests.Pager` and use the shared `requests.Pagination` types defined in `backend/app/requests/pagination.go`; DO NOT redefine pagination or pager structs in local DTOs.
|
||||
- MUST: The JSON response for paginated data MUST follow the `requests.Pager` layout: `{ "page": 1, "limit": 10, "total": 100, "items": [...] }`.
|
||||
- DO keep controller methods thin: parse/bind → call `services.*` → return result/error.
|
||||
- DO regenerate code after changes (routes/docs/models).
|
||||
- MUST: in `backend/app/services`, prefer the generated GORM-Gen DAO (`backend/database/models/*`) for DB access; treat raw `*gorm.DB` usage as a last resort.
|
||||
@@ -64,7 +67,7 @@ Place above the handler function:
|
||||
|
||||
Common `@Success` patterns:
|
||||
|
||||
- Paginated list: `requests.Pager{items=dto.Item}`
|
||||
- Paginated list: `requests.Pager{items=[]dto.Item}`
|
||||
- Single object: `dto.Item`
|
||||
- Array: `{array} dto.Item`
|
||||
|
||||
@@ -205,7 +208,7 @@ In this case:
|
||||
### Job(一次性任务)
|
||||
|
||||
- `Kind() string`:任务类型标识(job kind);改名会导致“新旧任务类型不一致”。
|
||||
- `InsertOpts() river.InsertOpts`:默认入队参数(队列、优先级、最大重试、唯一任务策略等)。
|
||||
- `InsertOpts() river.InsertOpts` : 默认入队参数(队列、优先级、最大重试、唯一任务策略等)。
|
||||
- `UniqueID() string`(项目约定):周期任务 handle 的稳定 key;通常 `return Kind()`。
|
||||
|
||||
### Worker(执行器)
|
||||
@@ -456,4 +459,4 @@ func (s *XxxTestSuite) Test_Method() {
|
||||
So(got, ShouldBeNil)
|
||||
})
|
||||
}
|
||||
```
|
||||
```
|
||||
Reference in New Issue
Block a user