fix
This commit is contained in:
@@ -484,6 +484,79 @@ async update(id, dto) {
|
||||
|
||||
---
|
||||
|
||||
## 三端分离开发规范
|
||||
|
||||
### 三端定义
|
||||
|
||||
| 端 | 说明 | 前端项目 | API路由前缀 |
|
||||
|---|---|---|---|
|
||||
| 用户端 | C端普通用户 | 小程序用户页面 (`pages/*`) | `/xxx` (无前缀) |
|
||||
| 商家端 | B端商家 | 小程序商家页面 (`pages/seller/*`) + 商家管理后台 (`merchant-admin`) | `/seller/xxx` |
|
||||
| 平台端 | 平台管理员 | 平台管理后台 (`platform-admin`) | `/admin/xxx` |
|
||||
|
||||
### 后端 Controller 文件命名规范
|
||||
|
||||
每个模块的控制器按端拆分为独立文件,命名格式:`{module}-{端}.controller.ts`
|
||||
|
||||
```
|
||||
modules/merchant/
|
||||
├── merchant-public.controller.ts # 用户端 @Controller('merchants')
|
||||
├── merchant-seller.controller.ts # 商家端 @Controller('seller/merchant')
|
||||
├── merchant-admin.controller.ts # 管理端 @Controller('admin/merchants')
|
||||
├── merchant.service.ts # 共享 Service
|
||||
├── merchant.module.ts # 模块定义
|
||||
└── dto/
|
||||
```
|
||||
|
||||
**命名对照**:
|
||||
- `*-public.controller.ts` → 用户端(公开接口,无Guard或JwtAuthGuard)
|
||||
- `*-seller.controller.ts` → 商家端(SellerJwtAuthGuard)
|
||||
- `*-user.controller.ts` → 用户端(需登录,JwtAuthGuard)
|
||||
- `*-admin.controller.ts` → 管理端(JwtAuthGuard + RolesGuard + @Roles('admin'))
|
||||
|
||||
### 小程序 API 文件目录规范
|
||||
|
||||
```
|
||||
apps/miniapp/src/api/
|
||||
├── user/ # 用户端 API
|
||||
│ ├── auth.ts # /auth/*, /user/profile
|
||||
│ ├── merchant.ts # /merchants/* (公开)
|
||||
│ ├── room.ts # /rooms/* (公开)
|
||||
│ ├── order.ts # /orders/*
|
||||
│ ├── review.ts # /reviews/*
|
||||
│ └── invite.ts # /user/activity/invite/*
|
||||
└── seller/ # 商家端 API
|
||||
├── auth.ts # /seller/auth/*
|
||||
├── merchant.ts # /seller/merchant/*
|
||||
├── room.ts # /seller/rooms/*
|
||||
├── room-calendar.ts # /seller/room-calendar/*
|
||||
└── order.ts # /seller/orders/*
|
||||
```
|
||||
|
||||
### Guard 使用对照
|
||||
|
||||
| 端 | Guard | Token | 装饰器 |
|
||||
|---|---|---|---|
|
||||
| 用户端(公开) | 无 | 无 | 无 |
|
||||
| 用户端(需登录) | JwtAuthGuard | Bearer Token | @CurrentUser('sub') |
|
||||
| 商家端 | SellerJwtAuthGuard | Bearer sellerToken | @CurrentSeller('sub') |
|
||||
| 管理端 | JwtAuthGuard + RolesGuard | Bearer adminToken | @CurrentUser('sub') + @Roles('admin') |
|
||||
|
||||
### 新增模块开发清单
|
||||
|
||||
新增业务模块时,按以下步骤操作:
|
||||
|
||||
1. 创建 `modules/{module}/` 目录
|
||||
2. 创建 `dto/{module}.dto.ts`
|
||||
3. 创建 `{module}.service.ts`
|
||||
4. 按需创建控制器文件:`{module}-public.controller.ts`、`{module}-seller.controller.ts`、`{module}-admin.controller.ts`
|
||||
5. 创建 `{module}.module.ts`,引用所有控制器和共享 Service
|
||||
6. 在 `app.module.ts` 中注册新模块
|
||||
7. 小程序端按端创建 API 文件:`api/user/{module}.ts` 或 `api/seller/{module}.ts`
|
||||
8. 商家管理后台/平台管理后台按需添加 API 文件
|
||||
|
||||
---
|
||||
|
||||
## 商家订单管理
|
||||
|
||||
### 商家订单接口
|
||||
|
||||
Reference in New Issue
Block a user