Files
soul-yongping/.cursor/rules/soul-api-boundary.mdc

34 lines
1.9 KiB
Plaintext
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.

---
description: soul-api 路由与使用方边界,防止管理端与小程序接口互窜
globs: soul-api/**/*.go
alwaysApply: false
---
# soul-api 开发边界(防互窜)
在 **soul-api/** 下新增、优化或编辑 Go 代码(尤其是路由与 handler必须遵守以下约束
## 路由按使用方归类(强制)
- **仅管理端用的接口**:只挂在 `admin` 或 `db` 组(`/api/admin/*`、`/api/db/*`**不得**在 `miniprogram` 组注册。
- **仅小程序用的接口**:只挂在 `miniprogram` 组(`/api/miniprogram/*`**不得**仅在 admin/db 下注册而让小程序去调 `/api/xxx`。
- **两端共用的接口**:在 `api` 下挂一份,并在 `miniprogram` 组内用同一 handler 再挂一遍,保证小程序统一走 `/api/miniprogram/xxx`handler 注释中标明使用方(如「小程序-提现记录」「管理端-提现列表」)。
## 禁止行为
- 禁止在 `miniprogram` 组挂仅管理端调用的接口如后台审核、DB 初始化)。
- 禁止在 `admin`/`db` 组挂小程序专属逻辑(如 wx code 登录、小程序码生成),除非该逻辑同时以「管理端可用的形式」在 admin 下提供。
- 禁止在 handler 内混用「管理端路径」与「小程序路径」的语义(如根据 path 分支写两套业务而不按使用方拆 handler/路由)。
## 目录与职责
- 路由注册仅在 **internal/router** 中修改handler 在 **internal/handler**model 在 **internal/model**;配置在 **internal/config**;微信/支付在 **internal/wechat**。
- 新增接口流程:先确定使用方(小程序 / 管理端 / 共用) → 再决定挂到哪个 Group → 再实现或修改 handler。
## 参考
- 完整编码规范与 GORM/响应约定见 **.cursor/rules/soul-api-coding.mdc**。
- 归纳与对接要点见 **.cursor/skills/SKILL-API开发.md**。
违反上述路由归类或职责边界即视为「互窜」,需纠正后再提交。