代理后端出版

This commit is contained in:
2025-09-05 16:49:23 +08:00
parent e704c8abca
commit 141d1313d6
27 changed files with 6395 additions and 49 deletions

121
docs/README.md Normal file
View File

@@ -0,0 +1,121 @@
# 句容圈代理后台管理系统 API 文档
本目录包含了句容圈代理后台管理系统的完整 API 文档,使用 Swagger/OpenAPI 3.0 规范编写。
## 文档结构
### APIs 目录
包含各个模块的 API 接口文档:
- `auth.js` - 认证管理接口(登录、获取用户信息、登出)
- `agent.js` - 代理统计接口(统计数据、趋势分析、最新记录)
- `captcha.js` - 验证码接口(生成验证码、验证验证码)
- `commissions.js` - 佣金管理接口(佣金列表、详情、申请发放)
- `transfers.js` - 转账管理接口(转账记录查询)
- `upload.js` - 文件上传接口(各类文件上传、删除)
- `users.js` - 用户管理接口(用户列表、详情、数据导出)
### Schemas 目录
包含数据模型定义:
- `agent.js` - 代理数据模型
- `user.js` - 用户数据模型
- `commission.js` - 佣金记录数据模型
- `transfer.js` - 转账记录数据模型
- `security.js` - 安全认证配置
## 使用说明
### 1. 集成到项目
在你的 Express 应用中集成 Swagger UI
```javascript
const swaggerJsdoc = require('swagger-jsdoc');
const swaggerUi = require('swagger-ui-express');
const options = {
definition: {
openapi: '3.0.0',
info: {
title: '句容圈代理后台管理系统 API',
version: '1.0.0',
description: '句容圈代理后台管理系统的 RESTful API 文档',
},
servers: [
{
url: 'http://localhost:3000/api',
description: '开发环境',
},
],
},
apis: [
'./docs/apis/*.js',
'./docs/schemas/*.js',
],
};
const specs = swaggerJsdoc(options);
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(specs));
```
### 2. 访问文档
启动服务器后,访问 `http://localhost:3000/api-docs` 查看完整的 API 文档。
### 3. 认证说明
大部分 API 接口需要 JWT 认证,请在请求头中添加:
```
Authorization: Bearer <your-jwt-token>
```
### 4. 响应格式
所有 API 响应都遵循统一格式:
```json
{
"success": true,
"data": {},
"message": "操作成功"
}
```
### 5. 分页格式
列表接口支持分页,响应格式:
```json
{
"success": true,
"data": {
"items": [],
"total": 100,
"page": 1,
"limit": 10,
"totalPages": 10
}
}
```
## 开发指南
### 添加新接口文档
1.`apis/` 目录下创建或编辑对应的文件
2. 使用 Swagger JSDoc 注释格式编写文档
3. 如需要新的数据模型,在 `schemas/` 目录下添加
### 文档规范
- 使用中文描述
- 包含完整的请求参数和响应示例
- 标明必需参数和可选参数
- 提供错误响应说明
- 使用合适的 HTTP 状态码
## 更新日志
- v1.0.0 - 初始版本,包含所有核心 API 接口文档

253
docs/apis/agent.js Normal file
View File

@@ -0,0 +1,253 @@
/**
* @swagger
* tags:
* name: 代理统计
* description: 代理统计数据相关接口
*/
/**
* @swagger
* /agent/stats:
* get:
* summary: 获取代理统计数据
* tags: [代理统计]
* security:
* - bearerAuth: []
* responses:
* 200:
* description: 获取成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* type: object
* properties:
* totalUsers:
* type: integer
* description: 总用户数
* totalCommissions:
* type: number
* format: decimal
* description: 总佣金金额
* pendingCommissions:
* type: number
* format: decimal
* description: 待发放佣金
* thisMonthUsers:
* type: integer
* description: 本月新增用户数
* thisMonthCommissions:
* type: number
* format: decimal
* description: 本月佣金收入
* 401:
* description: 未授权
* 500:
* description: 服务器错误
*/
/**
* @swagger
* /agent/user-growth-trend:
* get:
* summary: 获取用户增长趋势
* tags: [代理统计]
* security:
* - bearerAuth: []
* parameters:
* - in: query
* name: days
* schema:
* type: integer
* default: 30
* description: 查询天数
* responses:
* 200:
* description: 获取成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* type: array
* items:
* type: object
* properties:
* date:
* type: string
* format: date
* description: 日期
* count:
* type: integer
* description: 新增用户数
* 401:
* description: 未授权
* 500:
* description: 服务器错误
*/
/**
* @swagger
* /agent/commission-trend:
* get:
* summary: 获取佣金收入趋势
* tags: [代理统计]
* security:
* - bearerAuth: []
* parameters:
* - in: query
* name: days
* schema:
* type: integer
* default: 30
* description: 查询天数
* responses:
* 200:
* description: 获取成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* type: array
* items:
* type: object
* properties:
* date:
* type: string
* format: date
* description: 日期
* amount:
* type: number
* format: decimal
* description: 佣金金额
* 401:
* description: 未授权
* 500:
* description: 服务器错误
*/
/**
* @swagger
* /agent/commission-distribution:
* get:
* summary: 获取佣金类型分布
* tags: [代理统计]
* security:
* - bearerAuth: []
* responses:
* 200:
* description: 获取成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* type: array
* items:
* type: object
* properties:
* type:
* type: string
* description: 佣金类型
* amount:
* type: number
* format: decimal
* description: 佣金金额
* count:
* type: integer
* description: 记录数量
* 401:
* description: 未授权
* 500:
* description: 服务器错误
*/
/**
* @swagger
* /agent/recent-users:
* get:
* summary: 获取最新下级用户
* tags: [代理统计]
* security:
* - bearerAuth: []
* parameters:
* - in: query
* name: limit
* schema:
* type: integer
* default: 10
* description: 返回数量限制
* responses:
* 200:
* description: 获取成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* type: array
* items:
* $ref: '#/components/schemas/User'
* 401:
* description: 未授权
* 500:
* description: 服务器错误
*/
/**
* @swagger
* /agent/recent-commissions:
* get:
* summary: 获取最新佣金记录
* tags: [代理统计]
* security:
* - bearerAuth: []
* parameters:
* - in: query
* name: limit
* schema:
* type: integer
* default: 10
* description: 返回数量限制
* responses:
* 200:
* description: 获取成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* type: array
* items:
* $ref: '#/components/schemas/Commission'
* 401:
* description: 未授权
* 500:
* description: 服务器错误
*/

114
docs/apis/auth.js Normal file
View File

@@ -0,0 +1,114 @@
/**
* @swagger
* tags:
* name: 认证
* description: 代理认证相关接口
*/
/**
* @swagger
* /auth/login:
* post:
* summary: 代理登录
* tags: [认证]
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - phone
* - password
* properties:
* phone:
* type: string
* description: 代理手机号
* password:
* type: string
* description: 登录密码
* captchaId:
* type: string
* description: 验证码ID
* captchaText:
* type: string
* description: 验证码文本
* responses:
* 200:
* description: 登录成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* type: object
* properties:
* token:
* type: string
* description: JWT令牌
* agent:
* $ref: '#/components/schemas/Agent'
* 400:
* description: 参数错误
* 401:
* description: 登录失败
*/
/**
* @swagger
* /auth/me:
* get:
* summary: 获取当前代理信息
* tags: [认证]
* security:
* - bearerAuth: []
* responses:
* 200:
* description: 获取成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* $ref: '#/components/schemas/Agent'
* 401:
* description: 未授权或令牌无效
* 500:
* description: 服务器错误
*/
/**
* @swagger
* /auth/logout:
* post:
* summary: 代理登出
* tags: [认证]
* security:
* - bearerAuth: []
* responses:
* 200:
* description: 登出成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* message:
* type: string
* example: "登出成功"
* 401:
* description: 未授权
* 500:
* description: 服务器错误
*/

95
docs/apis/captcha.js Normal file
View File

@@ -0,0 +1,95 @@
/**
* @swagger
* tags:
* name: 验证码
* description: 验证码生成和验证相关接口
*/
/**
* @swagger
* /captcha/generate:
* get:
* summary: 生成图形验证码
* tags: [验证码]
* responses:
* 200:
* description: 生成成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* type: object
* properties:
* captchaId:
* type: string
* description: 验证码唯一标识
* captchaImage:
* type: string
* description: SVG格式的验证码图片
* 500:
* description: 服务器错误
*/
/**
* @swagger
* /captcha/verify:
* post:
* summary: 验证图形验证码
* tags: [验证码]
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - captchaId
* - captchaText
* properties:
* captchaId:
* type: string
* description: 验证码唯一标识
* captchaText:
* type: string
* description: 用户输入的验证码文本
* responses:
* 200:
* description: 验证成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* message:
* type: string
* example: "验证码验证成功"
* 400:
* description: 验证失败
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: false
* message:
* type: string
* examples:
* invalid_params:
* value: "验证码ID和文本不能为空"
* not_found:
* value: "验证码不存在或已过期"
* incorrect:
* value: "验证码错误"
* 500:
* description: 服务器错误
*/

273
docs/apis/commissions.js Normal file
View File

@@ -0,0 +1,273 @@
/**
* @swagger
* tags:
* name: 佣金管理
* description: 佣金记录管理相关接口
*/
/**
* @swagger
* /commissions:
* get:
* summary: 获取佣金记录列表
* tags: [佣金管理]
* security:
* - bearerAuth: []
* parameters:
* - in: query
* name: page
* schema:
* type: integer
* default: 1
* description: 页码
* - in: query
* name: limit
* schema:
* type: integer
* default: 10
* description: 每页数量
* - in: query
* name: search
* schema:
* type: string
* description: 搜索关键词(用户名、手机号)
* - in: query
* name: status
* schema:
* type: string
* enum: [pending, paid, cancelled]
* description: 佣金状态
* - in: query
* name: commission_type
* schema:
* type: string
* description: 佣金类型
* - in: query
* name: start_date
* schema:
* type: string
* format: date
* description: 开始日期
* - in: query
* name: end_date
* schema:
* type: string
* format: date
* description: 结束日期
* - in: query
* name: min_amount
* schema:
* type: number
* description: 最小金额
* - in: query
* name: max_amount
* schema:
* type: number
* description: 最大金额
* - in: query
* name: sort_by
* schema:
* type: string
* default: created_at
* description: 排序字段
* - in: query
* name: sort_order
* schema:
* type: string
* enum: [asc, desc]
* default: desc
* description: 排序方向
* responses:
* 200:
* description: 获取成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* type: object
* properties:
* commissions:
* type: array
* items:
* $ref: '#/components/schemas/Commission'
* total:
* type: integer
* description: 总记录数
* page:
* type: integer
* description: 当前页码
* limit:
* type: integer
* description: 每页数量
* totalPages:
* type: integer
* description: 总页数
* stats:
* type: object
* properties:
* totalAmount:
* type: number
* format: decimal
* description: 总佣金金额
* pendingAmount:
* type: number
* format: decimal
* description: 待发放金额
* paidAmount:
* type: number
* format: decimal
* description: 已发放金额
* 401:
* description: 未授权
* 500:
* description: 服务器错误
*/
/**
* @swagger
* /commissions/{id}:
* get:
* summary: 获取单个佣金记录详情
* tags: [佣金管理]
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: id
* required: true
* schema:
* type: integer
* description: 佣金记录ID
* responses:
* 200:
* description: 获取成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* $ref: '#/components/schemas/Commission'
* 401:
* description: 未授权
* 404:
* description: 佣金记录不存在
* 500:
* description: 服务器错误
*/
/**
* @swagger
* /commissions/{id}/request-payment:
* post:
* summary: 申请单个佣金发放
* tags: [佣金管理]
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: id
* required: true
* schema:
* type: integer
* description: 佣金记录ID
* responses:
* 200:
* description: 申请成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* message:
* type: string
* example: "佣金发放申请已提交"
* 400:
* description: 申请失败
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: false
* message:
* type: string
* example: "该佣金记录不可申请发放"
* 401:
* description: 未授权
* 404:
* description: 佣金记录不存在
* 500:
* description: 服务器错误
*/
/**
* @swagger
* /commissions/batch-request-payment:
* post:
* summary: 批量申请佣金发放
* tags: [佣金管理]
* security:
* - bearerAuth: []
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - commission_ids
* properties:
* commission_ids:
* type: array
* items:
* type: integer
* description: 佣金记录ID数组
* responses:
* 200:
* description: 批量申请成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* type: object
* properties:
* successCount:
* type: integer
* description: 成功申请数量
* failedCount:
* type: integer
* description: 失败申请数量
* failedIds:
* type: array
* items:
* type: integer
* description: 失败的佣金记录ID
* message:
* type: string
* example: "批量申请完成"
* 400:
* description: 参数错误
* 401:
* description: 未授权
* 500:
* description: 服务器错误
*/

134
docs/apis/transfers.js Normal file
View File

@@ -0,0 +1,134 @@
/**
* @swagger
* tags:
* name: 转账管理
* description: 转账记录管理相关接口
*/
/**
* @swagger
* /transfers:
* get:
* summary: 获取代理下级用户转账记录列表
* tags: [转账管理]
* security:
* - bearerAuth: []
* parameters:
* - in: query
* name: page
* schema:
* type: integer
* default: 1
* description: 页码
* - in: query
* name: limit
* schema:
* type: integer
* default: 10
* description: 每页数量
* - in: query
* name: search
* schema:
* type: string
* description: 搜索关键词(用户名、手机号、转账单号)
* - in: query
* name: status
* schema:
* type: string
* enum: [pending, success, failed, cancelled]
* description: 转账状态
* - in: query
* name: type
* schema:
* type: string
* enum: [deposit, withdraw, transfer]
* description: 转账类型
* - in: query
* name: start_date
* schema:
* type: string
* format: date
* description: 开始日期
* - in: query
* name: end_date
* schema:
* type: string
* format: date
* description: 结束日期
* - in: query
* name: min_amount
* schema:
* type: number
* description: 最小金额
* - in: query
* name: max_amount
* schema:
* type: number
* description: 最大金额
* - in: query
* name: sort_by
* schema:
* type: string
* default: created_at
* description: 排序字段
* - in: query
* name: sort_order
* schema:
* type: string
* enum: [asc, desc]
* default: desc
* description: 排序方向
* responses:
* 200:
* description: 获取成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* type: object
* properties:
* transfers:
* type: array
* items:
* $ref: '#/components/schemas/Transfer'
* total:
* type: integer
* description: 总记录数
* page:
* type: integer
* description: 当前页码
* limit:
* type: integer
* description: 每页数量
* totalPages:
* type: integer
* description: 总页数
* stats:
* type: object
* properties:
* totalAmount:
* type: number
* format: decimal
* description: 总转账金额
* successAmount:
* type: number
* format: decimal
* description: 成功转账金额
* pendingAmount:
* type: number
* format: decimal
* description: 待处理转账金额
* failedAmount:
* type: number
* format: decimal
* description: 失败转账金额
* 401:
* description: 未授权
* 500:
* description: 服务器错误
*/

364
docs/apis/upload.js Normal file
View File

@@ -0,0 +1,364 @@
/**
* @swagger
* tags:
* name: 文件上传
* description: 文件上传管理相关接口
*/
/**
* @swagger
* /upload/single:
* post:
* summary: 单文件上传
* tags: [文件上传]
* security:
* - bearerAuth: []
* requestBody:
* required: true
* content:
* multipart/form-data:
* schema:
* type: object
* properties:
* file:
* type: string
* format: binary
* description: 上传的文件
* responses:
* 200:
* description: 上传成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* type: object
* properties:
* filename:
* type: string
* description: 文件名
* originalname:
* type: string
* description: 原始文件名
* path:
* type: string
* description: 文件路径
* size:
* type: integer
* description: 文件大小(字节)
* mimetype:
* type: string
* description: 文件MIME类型
* url:
* type: string
* description: 文件访问URL
* 400:
* description: 上传失败
* 401:
* description: 未授权
* 413:
* description: 文件过大
* 500:
* description: 服务器错误
*/
/**
* @swagger
* /upload/multiple:
* post:
* summary: 多文件上传
* tags: [文件上传]
* security:
* - bearerAuth: []
* requestBody:
* required: true
* content:
* multipart/form-data:
* schema:
* type: object
* properties:
* files:
* type: array
* items:
* type: string
* format: binary
* description: 上传的文件数组
* responses:
* 200:
* description: 上传成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* type: array
* items:
* type: object
* properties:
* filename:
* type: string
* description: 文件名
* originalname:
* type: string
* description: 原始文件名
* path:
* type: string
* description: 文件路径
* size:
* type: integer
* description: 文件大小(字节)
* mimetype:
* type: string
* description: 文件MIME类型
* url:
* type: string
* description: 文件访问URL
* 400:
* description: 上传失败
* 401:
* description: 未授权
* 413:
* description: 文件过大
* 500:
* description: 服务器错误
*/
/**
* @swagger
* /upload/avatar:
* post:
* summary: 头像上传
* tags: [文件上传]
* security:
* - bearerAuth: []
* requestBody:
* required: true
* content:
* multipart/form-data:
* schema:
* type: object
* properties:
* avatar:
* type: string
* format: binary
* description: 头像文件支持jpg, jpeg, png, gif格式最大2MB
* responses:
* 200:
* description: 上传成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* type: object
* properties:
* filename:
* type: string
* description: 文件名
* url:
* type: string
* description: 头像访问URL
* 400:
* description: 文件格式不支持或文件过大
* 401:
* description: 未授权
* 500:
* description: 服务器错误
*/
/**
* @swagger
* /upload/qrcode:
* post:
* summary: 二维码上传
* tags: [文件上传]
* security:
* - bearerAuth: []
* requestBody:
* required: true
* content:
* multipart/form-data:
* schema:
* type: object
* properties:
* qrcode:
* type: string
* format: binary
* description: 二维码文件支持jpg, jpeg, png格式最大5MB
* responses:
* 200:
* description: 上传成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* type: object
* properties:
* filename:
* type: string
* description: 文件名
* url:
* type: string
* description: 二维码访问URL
* 400:
* description: 文件格式不支持或文件过大
* 401:
* description: 未授权
* 500:
* description: 服务器错误
*/
/**
* @swagger
* /upload/idcard:
* post:
* summary: 身份证上传
* tags: [文件上传]
* security:
* - bearerAuth: []
* requestBody:
* required: true
* content:
* multipart/form-data:
* schema:
* type: object
* properties:
* idcard:
* type: string
* format: binary
* description: 身份证文件支持jpg, jpeg, png格式最大10MB
* responses:
* 200:
* description: 上传成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* type: object
* properties:
* filename:
* type: string
* description: 文件名
* url:
* type: string
* description: 身份证访问URL
* 400:
* description: 文件格式不支持或文件过大
* 401:
* description: 未授权
* 500:
* description: 服务器错误
*/
/**
* @swagger
* /upload/license:
* post:
* summary: 营业执照上传
* tags: [文件上传]
* security:
* - bearerAuth: []
* requestBody:
* required: true
* content:
* multipart/form-data:
* schema:
* type: object
* properties:
* license:
* type: string
* format: binary
* description: 营业执照文件支持jpg, jpeg, png, pdf格式最大10MB
* responses:
* 200:
* description: 上传成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* type: object
* properties:
* filename:
* type: string
* description: 文件名
* url:
* type: string
* description: 营业执照访问URL
* 400:
* description: 文件格式不支持或文件过大
* 401:
* description: 未授权
* 500:
* description: 服务器错误
*/
/**
* @swagger
* /upload/file:
* delete:
* summary: 删除文件
* tags: [文件上传]
* security:
* - bearerAuth: []
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - filename
* properties:
* filename:
* type: string
* description: 要删除的文件名
* responses:
* 200:
* description: 删除成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* message:
* type: string
* example: "文件删除成功"
* 400:
* description: 参数错误
* 401:
* description: 未授权
* 404:
* description: 文件不存在
* 500:
* description: 服务器错误
*/

186
docs/apis/users.js Normal file
View File

@@ -0,0 +1,186 @@
/**
* @swagger
* tags:
* name: 用户管理
* description: 用户管理相关接口
*/
/**
* @swagger
* /users:
* get:
* summary: 获取代理下级用户列表
* tags: [用户管理]
* security:
* - bearerAuth: []
* parameters:
* - in: query
* name: page
* schema:
* type: integer
* default: 1
* description: 页码
* - in: query
* name: limit
* schema:
* type: integer
* default: 10
* description: 每页数量
* - in: query
* name: search
* schema:
* type: string
* description: 搜索关键词(用户名、手机号、邮箱)
* - in: query
* name: role
* schema:
* type: string
* description: 用户角色筛选
* - in: query
* name: city
* schema:
* type: string
* description: 城市筛选
* - in: query
* name: area
* schema:
* type: string
* description: 区域筛选
* - in: query
* name: sort_by
* schema:
* type: string
* default: created_at
* description: 排序字段
* - in: query
* name: sort_order
* schema:
* type: string
* enum: [asc, desc]
* default: desc
* description: 排序方向
* responses:
* 200:
* description: 获取成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* type: object
* properties:
* users:
* type: array
* items:
* $ref: '#/components/schemas/User'
* total:
* type: integer
* description: 总记录数
* page:
* type: integer
* description: 当前页码
* limit:
* type: integer
* description: 每页数量
* totalPages:
* type: integer
* description: 总页数
* 401:
* description: 未授权
* 500:
* description: 服务器错误
*/
/**
* @swagger
* /users/{id}:
* get:
* summary: 获取用户详情
* tags: [用户管理]
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: id
* required: true
* schema:
* type: integer
* description: 用户ID
* responses:
* 200:
* description: 获取成功
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* data:
* $ref: '#/components/schemas/User'
* 401:
* description: 未授权
* 404:
* description: 用户不存在
* 500:
* description: 服务器错误
*/
/**
* @swagger
* /users/export/data:
* get:
* summary: 导出用户数据
* tags: [用户管理]
* security:
* - bearerAuth: []
* parameters:
* - in: query
* name: format
* schema:
* type: string
* enum: [excel, csv]
* default: excel
* description: 导出格式
* - in: query
* name: search
* schema:
* type: string
* description: 搜索关键词(用户名、手机号、邮箱)
* - in: query
* name: role
* schema:
* type: string
* description: 用户角色筛选
* - in: query
* name: city
* schema:
* type: string
* description: 城市筛选
* - in: query
* name: area
* schema:
* type: string
* description: 区域筛选
* responses:
* 200:
* description: 导出成功
* content:
* application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
* schema:
* type: string
* format: binary
* text/csv:
* schema:
* type: string
* format: binary
* 401:
* description: 未授权
* 500:
* description: 服务器错误
*/

32
docs/schemas/agent.js Normal file
View File

@@ -0,0 +1,32 @@
/**
* @swagger
* components:
* schemas:
* Agent:
* type: object
* required:
* - id
* - phone
* - name
* properties:
* id:
* type: integer
* description: 代理ID
* phone:
* type: string
* description: 代理手机号
* name:
* type: string
* description: 代理名称
* status:
* type: integer
* description: 代理状态 (1-正常, 0-禁用)
* created_at:
* type: string
* format: date-time
* description: 创建时间
* updated_at:
* type: string
* format: date-time
* description: 更新时间
*/

View File

@@ -0,0 +1,59 @@
/**
* @swagger
* components:
* schemas:
* Commission:
* type: object
* required:
* - id
* - agent_id
* - user_id
* - amount
* - commission_type
* - status
* properties:
* id:
* type: integer
* description: 佣金记录ID
* agent_id:
* type: integer
* description: 代理ID
* user_id:
* type: integer
* description: 用户ID
* amount:
* type: number
* format: decimal
* description: 佣金金额
* commission_type:
* type: string
* description: 佣金类型
* status:
* type: string
* enum: [pending, paid, cancelled]
* description: 佣金状态
* description:
* type: string
* description: 佣金描述
* order_id:
* type: string
* description: 关联订单ID
* payment_method:
* type: string
* description: 支付方式
* payment_time:
* type: string
* format: date-time
* description: 支付时间
* created_at:
* type: string
* format: date-time
* description: 创建时间
* updated_at:
* type: string
* format: date-time
* description: 更新时间
* user:
* $ref: '#/components/schemas/User'
* description: 关联用户信息
*/

10
docs/schemas/security.js Normal file
View File

@@ -0,0 +1,10 @@
/**
* @swagger
* components:
* securitySchemes:
* bearerAuth:
* type: http
* scheme: bearer
* bearerFormat: JWT
* description: "JWT认证请在请求头中添加 Authorization: Bearer <token>"
*/

77
docs/schemas/transfer.js Normal file
View File

@@ -0,0 +1,77 @@
/**
* @swagger
* components:
* schemas:
* Transfer:
* type: object
* required:
* - id
* - user_id
* - amount
* - type
* - status
* properties:
* id:
* type: integer
* description: 转账记录ID
* user_id:
* type: integer
* description: 用户ID
* amount:
* type: number
* format: decimal
* description: 转账金额
* type:
* type: string
* enum: [deposit, withdraw, transfer]
* description: 转账类型
* status:
* type: string
* enum: [pending, success, failed, cancelled]
* description: 转账状态
* transaction_id:
* type: string
* description: 交易单号
* payment_method:
* type: string
* description: 支付方式
* bank_info:
* type: object
* properties:
* bank_name:
* type: string
* description: 银行名称
* account_number:
* type: string
* description: 账户号码
* account_name:
* type: string
* description: 账户名称
* description: 银行信息
* description:
* type: string
* description: 转账描述
* fee:
* type: number
* format: decimal
* description: 手续费
* actual_amount:
* type: number
* format: decimal
* description: 实际到账金额
* processed_at:
* type: string
* format: date-time
* description: 处理时间
* created_at:
* type: string
* format: date-time
* description: 创建时间
* updated_at:
* type: string
* format: date-time
* description: 更新时间
* user:
* $ref: '#/components/schemas/User'
* description: 关联用户信息
*/

51
docs/schemas/user.js Normal file
View File

@@ -0,0 +1,51 @@
/**
* @swagger
* components:
* schemas:
* User:
* type: object
* required:
* - id
* - phone
* - username
* properties:
* id:
* type: integer
* description: 用户ID
* phone:
* type: string
* description: 用户手机号
* username:
* type: string
* description: 用户名
* email:
* type: string
* format: email
* description: 用户邮箱
* avatar:
* type: string
* description: 用户头像URL
* role:
* type: string
* description: 用户角色
* status:
* type: integer
* description: 用户状态 (1-正常, 0-禁用)
* city:
* type: string
* description: 所在城市
* area:
* type: string
* description: 所在区域
* agent_id:
* type: integer
* description: 所属代理ID
* created_at:
* type: string
* format: date-time
* description: 创建时间
* updated_at:
* type: string
* format: date-time
* description: 更新时间
*/