[api][shop] add product/searchproduct/createorder/batch

This commit is contained in:
2025-05-29 00:31:12 +08:00
parent f824b600f3
commit 30e4ffd8a9
18 changed files with 1254 additions and 2 deletions
+204
View File
@@ -0,0 +1,204 @@
# quantum_stack_interview
Base URLs: http://127.0.0.1:8000
## GET 搜索商品
GET /shop/product/search/
支持关键词搜索,包含名字、编号、描述、关键词(或者应该叫标签)
### 请求参数
|名称|位置|类型|必选|说明|
|---|---|---|---|---|
|q|query|string| 是 |关键词|
|page|query|integer| 否 |页码|
|page_size|query|integer| 否 |页面大小,最大100|
> 返回示例
> 200 Response
```json
{
"products": [
{
"id": 10,
"name": "e",
"description": "效关科造区最飞阶。就见除据区眼求该合。今新料。",
"price": "19.20",
"stock": 7387915975153562,
"keywords": "天也商"
},
{
"id": 11,
"name": "e",
"description": "效关科造区最飞阶。就见除据区眼求该合。今新料。",
"price": "123.20",
"stock": 7387915975153562,
"keywords": "天也商"
}
]
}
```
### 返回结果
|状态码|状态码含义|说明|数据模型|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|none|Inline|
### 返回数据结构
状态码 **200**
|名称|类型|必选|约束|中文名|说明|
|---|---|---|---|---|---|
|» products|[object]|true|none||none|
|»» id|integer|true|none||none|
|»» name|string|true|none|商品名称|none|
|»» description|string|true|none|商品描述|none|
|»» price|string|true|none|商品价格 |none|
|»» stock|integer|true|none|商品库存|none|
|»» keywords|string|true|none|商品关键词|none|
## POST 批量下单接口
POST /shop/order/batch/
批量下单商品
> Body 请求参数
```json
{
"items": [
{
"product_id": 0,
"quantity": 0
}
]
}
```
### 请求参数
|名称|位置|类型|必选|中文名|说明|
|---|---|---|---|---|---|
|body|body|object| 否 ||none|
|» items|body|[object]| 是 ||none|
|»» product_id|body|integer| 是 | 下单商品id|none|
|»» quantity|body|integer| 是 | 下单数量|none|
> 返回示例
> 200 Response
```json
{
"order_id": 13,
"results": [
{
"product_id": 1,
"status": "success"
},
{
"product_id": 5,
"status": "success"
},
{
"product_id": 86,
"status": "failed",
"reason": "商品不存在"
}
]
}
```
### 返回结果
|状态码|状态码含义|说明|数据模型|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|none|Inline|
### 返回数据结构
状态码 **200**
|名称|类型|必选|约束|中文名|说明|
|---|---|---|---|---|---|
|» order_id|integer|true|none||none|
|» results|[object]|true|none||none|
|»» product_id|integer|true|none|下单商品id|none|
|»» status|string|true|none|下单结果|none|
|»» reason|string|false|none|错误信息|none|
## POST 新增商品
POST /shop/product/create/
新增商品
> Body 请求参数
```json
{
"data": {
"name": "string",
"price": 0,
"stock": 0,
"description": "string",
"keywords": "string"
}
}
```
### 请求参数
|名称|位置|类型|必选|中文名|说明|
|---|---|---|---|---|---|
|body|body|object| 否 ||none|
|» data|body|object| 是 ||none|
|»» name|body|string| 是 | 商品名称|none|
|»» price|body|integer| 是 | 商品价格|none|
|»» stock|body|integer| 是 | 商品库存|none|
|»» description|body|string| 否 | 商品描述|none|
|»» keywords|body|string| 否 | 商品关键词|none|
> 返回示例
> 200 Response
```json
{
"result": {
"id": 14,
"name": "x",
"description": "者车重转必维目马。作属时看区低验什声。无使山精出如。",
"price": "943941625",
"stock": 5203132084980572,
"keywords": "收适面"
}
}
```
### 返回结果
|状态码|状态码含义|说明|数据模型|
|---|---|---|---|
|200|[OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)|none|Inline|
### 返回数据结构
状态码 **200**
|名称|类型|必选|约束|中文名|说明|
|---|---|---|---|---|---|
|» result|object|true|none||none|
|»» id|integer|true|none||none|
|»» name|string|true|none|商品名称|none|
|»» description|string|true|none|商品描述|none|
|»» price|string|true|none|商品价格|none|
|»» stock|integer|true|none|商品库存|none|
|»» keywords|string|true|none|商品关键词|none|