docs: 更新项目文档,完善需求和技术细节

This commit is contained in:
ylweng
2025-09-01 01:23:49 +08:00
parent 816a51ae82
commit e1647902e2
4 changed files with 119 additions and 163 deletions

View File

@@ -6,18 +6,15 @@
## 基础信息
- **基础URL**: `http://localhost:3200/api/v1`
- **Base URL**: `http://localhost:3200/api/v1`
- **认证方式**: Bearer Token (JWT)
- **数据格式**: JSON
- **字符编码**: UTF-8
- **响应格式**: JSON
## 认证接口
### 用户注册
```http
POST /auth/register
```
**POST** `/auth/register`
**请求参数**:
@@ -30,6 +27,7 @@ POST /auth/register
| user_type | string | 否 | 用户类型farmer/buyer/admin |
**响应示例**:
```json
{
"code": 201,
@@ -47,9 +45,7 @@ POST /auth/register
### 用户登录
```http
POST /auth/login
```
**POST** `/auth/login`
**请求参数**:
@@ -59,6 +55,7 @@ POST /auth/login
| password | string | 是 | 密码 |
**响应示例**:
```json
{
"code": 200,
@@ -79,9 +76,7 @@ POST /auth/login
### 获取用户信息
```http
GET /users/me
```
**GET** `/users/me`
**请求头**:
```
@@ -89,6 +84,7 @@ Authorization: Bearer <token>
```
**响应示例**:
```json
{
"code": 200,
@@ -108,9 +104,7 @@ Authorization: Bearer <token>
### 更新用户信息
```http
PUT /users/{id}
```
**PUT** `/users/{id}`
**请求参数**:
@@ -124,9 +118,7 @@ PUT /users/{id}
### 获取商品列表
```http
GET /products
```
**GET** `/products`
**查询参数**:
@@ -142,6 +134,7 @@ GET /products
| sort_order | string | 排序方向asc/desc |
**响应示例**:
```json
{
"code": 200,
@@ -171,17 +164,13 @@ GET /products
### 获取商品详情
```http
GET /products/{id}
```
**GET** `/products/{id}`
## 订单接口
### 创建订单
```http
POST /orders
```
**POST** `/orders`
**请求参数**:
@@ -204,9 +193,7 @@ POST /orders
### 花卉识别
```http
POST /identifications/identify
```
**POST** `/identifications/identify`
**请求格式**: `multipart/form-data`
@@ -217,6 +204,7 @@ POST /identifications/identify
| image | file | 是 | 花卉图片文件 |
**响应示例**:
```json
{
"code": 200,
@@ -244,9 +232,7 @@ POST /identifications/identify
### 获取识别历史
```http
GET /identifications
```
**GET** `/identifications`
## 错误码说明

View File

@@ -4,7 +4,7 @@
## 基础信息
- **Base URL**: `http://localhost:3200/api`
- **Base URL**: `http://localhost:3200/api/v1`
- **认证方式**: Bearer Token (JWT)
- **响应格式**: JSON
@@ -258,9 +258,10 @@
| 错误码 | 说明 |
|--------|------|
| 200 | 成功 |
| 400 | 请求参数错误 |
| 201 | 创建成功 |
| 400 | 参数错误 |
| 401 | 未授权 |
| 403 | 权限不足 |
| 403 | 禁止访问 |
| 404 | 资源不存在 |
| 409 | 资源冲突 |
| 500 | 服务器内部错误 |