升级商城逻辑
This commit is contained in:
236
docs/apis/orders.js
Normal file
236
docs/apis/orders.js
Normal file
@@ -0,0 +1,236 @@
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Orders
|
||||
* description: 订单管理API
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /orders/create-from-cart:
|
||||
* post:
|
||||
* summary: 从购物车创建预订单
|
||||
* tags: [Orders]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - cartIds
|
||||
* properties:
|
||||
* cartIds:
|
||||
* type: array
|
||||
* items:
|
||||
* type: integer
|
||||
* description: 购物车商品ID数组
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 成功创建预订单
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* data:
|
||||
* $ref: '#/components/schemas/PreOrder'
|
||||
* 400:
|
||||
* description: 请求参数错误
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* message:
|
||||
* type: string
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /orders/pre-order/{id}:
|
||||
* get:
|
||||
* summary: 获取预订单详情
|
||||
* tags: [Orders]
|
||||
* 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
|
||||
* data:
|
||||
* type: object
|
||||
* properties:
|
||||
* preOrder:
|
||||
* $ref: '#/components/schemas/PreOrder'
|
||||
* items:
|
||||
* type: array
|
||||
* items:
|
||||
* type: object
|
||||
* properties:
|
||||
* product_id:
|
||||
* type: integer
|
||||
* product_name:
|
||||
* type: string
|
||||
* quantity:
|
||||
* type: integer
|
||||
* points_price:
|
||||
* type: integer
|
||||
* rongdou_price:
|
||||
* type: number
|
||||
* image_url:
|
||||
* type: string
|
||||
* 404:
|
||||
* description: 预订单不存在
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /orders/confirm:
|
||||
* post:
|
||||
* summary: 确认下单
|
||||
* tags: [Orders]
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - preOrderId
|
||||
* - shippingAddress
|
||||
* properties:
|
||||
* preOrderId:
|
||||
* type: integer
|
||||
* description: 预订单ID
|
||||
* shippingAddress:
|
||||
* type: string
|
||||
* description: 收货地址
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 订单确认成功
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* data:
|
||||
* type: object
|
||||
* properties:
|
||||
* orderId:
|
||||
* type: integer
|
||||
* orderNumber:
|
||||
* type: string
|
||||
* 400:
|
||||
* description: 请求参数错误或余额不足
|
||||
* 404:
|
||||
* description: 预订单不存在
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /orders:
|
||||
* get:
|
||||
* summary: 获取用户订单列表
|
||||
* tags: [Orders]
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: page
|
||||
* schema:
|
||||
* type: integer
|
||||
* default: 1
|
||||
* description: 页码
|
||||
* - in: query
|
||||
* name: limit
|
||||
* schema:
|
||||
* type: integer
|
||||
* default: 10
|
||||
* description: 每页数量
|
||||
* - in: query
|
||||
* name: status
|
||||
* schema:
|
||||
* type: string
|
||||
* enum: [pending, confirmed, shipped, delivered, cancelled]
|
||||
* description: 订单状态筛选
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 成功获取订单列表
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* data:
|
||||
* type: object
|
||||
* properties:
|
||||
* orders:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: '#/components/schemas/Order'
|
||||
* pagination:
|
||||
* type: object
|
||||
* properties:
|
||||
* page:
|
||||
* type: integer
|
||||
* limit:
|
||||
* type: integer
|
||||
* total:
|
||||
* type: integer
|
||||
* pages:
|
||||
* type: integer
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /orders/{id}:
|
||||
* get:
|
||||
* summary: 获取订单详情
|
||||
* tags: [Orders]
|
||||
* 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
|
||||
* data:
|
||||
* type: object
|
||||
* properties:
|
||||
* order:
|
||||
* $ref: '#/components/schemas/Order'
|
||||
* items:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: '#/components/schemas/OrderItem'
|
||||
* 404:
|
||||
* description: 订单不存在
|
||||
*/
|
||||
154
docs/apis/products.js
Normal file
154
docs/apis/products.js
Normal file
@@ -0,0 +1,154 @@
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Products
|
||||
* description: 商品管理API
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /products:
|
||||
* get:
|
||||
* summary: 获取商品列表
|
||||
* tags: [Products]
|
||||
* 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: category
|
||||
* schema:
|
||||
* type: string
|
||||
* description: 商品分类
|
||||
* - in: query
|
||||
* name: status
|
||||
* schema:
|
||||
* type: string
|
||||
* enum: [active, inactive]
|
||||
* description: 商品状态
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 成功获取商品列表
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* data:
|
||||
* type: object
|
||||
* properties:
|
||||
* products:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: '#/components/schemas/Product'
|
||||
* pagination:
|
||||
* type: object
|
||||
* properties:
|
||||
* page:
|
||||
* type: integer
|
||||
* limit:
|
||||
* type: integer
|
||||
* total:
|
||||
* type: integer
|
||||
* pages:
|
||||
* type: integer
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /products/categories:
|
||||
* get:
|
||||
* summary: 获取商品分类列表
|
||||
* tags: [Products]
|
||||
* responses:
|
||||
* 200:
|
||||
* description: 成功获取分类列表
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* success:
|
||||
* type: boolean
|
||||
* data:
|
||||
* type: array
|
||||
* items:
|
||||
* type: string
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /products/hot:
|
||||
* get:
|
||||
* summary: 获取热门商品
|
||||
* tags: [Products]
|
||||
* parameters:
|
||||
* - 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:
|
||||
* products:
|
||||
* type: array
|
||||
* items:
|
||||
* $ref: '#/components/schemas/Product'
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /products/{id}:
|
||||
* get:
|
||||
* summary: 获取商品详情
|
||||
* tags: [Products]
|
||||
* 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
|
||||
* data:
|
||||
* $ref: '#/components/schemas/Product'
|
||||
* 404:
|
||||
* description: 商品不存在
|
||||
*/
|
||||
Reference in New Issue
Block a user