post-bank-point-mall/.qoder/rules/api.md

40 lines
1.2 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.

---
trigger: model_decision
description: 后端API服务编码规范、技术栈、开发流程生成或修改后端API代码时参考
---
# API 编码规范
**技术栈**: Go 1.22.2 + Fiber v2 + GORM + Redis + Wire
**项目结构**:
- `biz/` - 业务层(接口定义)
- `data/` - 数据层(接口实现、数据库)
- `server/` - 路由层
- `service/` - 应用服务层
**开发流程**:
1. `conf/conf.go` - 添加配置
2. `biz/repository/` - 定义仓储接口
3. `data/repositoryimpl/` - 实现接口
4. `data/provider_set.go` - 注册 Provider
5. `server/http.go` - 添加路由
6. `make wire` - 生成依赖注入代码
7. 调用 code_review 进行代码评审
**常用命令**:
```bash
make wire # 生成 Wire
make build # 构建
```
**代码规范**:
- 符合 Go 基本原则(命名清晰、错误处理、上下文传递)
- 合理应用设计模式(工厂、策略、适配器等)
- 遵循设计原则SOLID、DRY、KISS
- 使用 TDD 驱动开发(先写测试,后写实现)
- 禁止硬编码(配置化、常量提取)
- 函数第一参数: `context.Context`
- 导入路径前缀: `trans_hub/app/ymt/post_bank_point_mall/service/...`