修改商城逻辑
This commit is contained in:
181
routes/users.js
181
routes/users.js
@@ -6,7 +6,131 @@ const dayjs = require('dayjs');
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
// 创建用户(管理员权限)
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Users
|
||||
* description: 用户管理API
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* components:
|
||||
* schemas:
|
||||
* User:
|
||||
* type: object
|
||||
* required:
|
||||
* - username
|
||||
* - password
|
||||
* - real_name
|
||||
* - id_card
|
||||
* properties:
|
||||
* id:
|
||||
* type: integer
|
||||
* description: 用户ID
|
||||
* username:
|
||||
* type: string
|
||||
* description: 用户名
|
||||
* role:
|
||||
* type: string
|
||||
* description: 用户角色
|
||||
* enum: [user, admin, merchant]
|
||||
* avatar:
|
||||
* type: string
|
||||
* description: 用户头像URL
|
||||
* points:
|
||||
* type: integer
|
||||
* description: 用户积分
|
||||
* real_name:
|
||||
* type: string
|
||||
* description: 真实姓名
|
||||
* id_card:
|
||||
* type: string
|
||||
* description: 身份证号
|
||||
* phone:
|
||||
* type: string
|
||||
* description: 手机号
|
||||
* is_system_account:
|
||||
* type: boolean
|
||||
* description: 是否为系统账户
|
||||
* created_at:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* description: 创建时间
|
||||
* updated_at:
|
||||
* type: string
|
||||
* format: date-time
|
||||
* description: 更新时间
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /users:
|
||||
* post:
|
||||
* summary: 创建用户(管理员权限)
|
||||
* tags: [Users]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - username
|
||||
* - password
|
||||
* - real_name
|
||||
* - id_card
|
||||
* properties:
|
||||
* username:
|
||||
* type: string
|
||||
* password:
|
||||
* type: string
|
||||
* role:
|
||||
* type: string
|
||||
* enum: [user, admin, merchant]
|
||||
* default: user
|
||||
* is_system_account:
|
||||
* type: boolean
|
||||
* default: false
|
||||
* real_name:
|
||||
* type: string
|
||||
* id_card:
|
||||
* type: string
|
||||
* wechat_qr:
|
||||
* type: string
|
||||
* alipay_qr:
|
||||
* type: string
|
||||
* bank_card:
|
||||
* type: string
|
||||
* unionpay_qr:
|
||||
* type: string
|
||||
* phone:
|
||||
* type: string
|
||||
* responses:
|
||||
* 201:
|
||||
* description: 用户创建成功
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* message:
|
||||
* type: string
|
||||
* user:
|
||||
* $ref: '#/components/schemas/User'
|
||||
* 400:
|
||||
* description: 请求参数错误
|
||||
* 401:
|
||||
* description: 未授权
|
||||
* 403:
|
||||
* description: 权限不足
|
||||
* 500:
|
||||
* description: 服务器错误
|
||||
*/
|
||||
router.post('/', auth, adminAuth, async (req, res) => {
|
||||
try {
|
||||
const db = getDB();
|
||||
@@ -88,7 +212,60 @@ router.post('/', auth, adminAuth, async (req, res) => {
|
||||
});
|
||||
|
||||
/**
|
||||
* 获取待审核用户列表(管理员权限)
|
||||
* @swagger
|
||||
* /users/pending-audit:
|
||||
* get:
|
||||
* summary: 获取待审核用户列表(管理员权限)
|
||||
* tags: [Users]
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: page
|
||||
* schema:
|
||||
* type: integer
|
||||
* default: 1
|
||||
* description: 页码
|
||||
* - in: query
|
||||
* name: limit
|
||||
* schema:
|
||||
* type: integer
|
||||
* default: 10
|
||||
* description: 每页数量
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 成功获取待审核用户列表
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* data:
|
||||
* type: object
|
||||
* properties:
|
||||
* users:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: '#/components/schemas/User'
|
||||
* pagination:
|
||||
* type: object
|
||||
* properties:
|
||||
* page:
|
||||
* type: integer
|
||||
* limit:
|
||||
* type: integer
|
||||
* total:
|
||||
* type: integer
|
||||
* pages:
|
||||
* type: integer
|
||||
* 401:
|
||||
* description: 未授权
|
||||
* 403:
|
||||
* description: 权限不足
|
||||
* 500:
|
||||
* description: 服务器错误
|
||||
*/
|
||||
router.get('/pending-audit', auth, adminAuth, async (req, res) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user