ソースを参照

添加 'research_platform_apidoc.md'

password_is_z16 2 ヶ月 前
コミット
82ea61026c
1 ファイル変更335 行追加0 行削除
  1. 335 0
      research_platform_apidoc.md

+ 335 - 0
research_platform_apidoc.md

@@ -0,0 +1,335 @@
+```markdown
+# 农业管理平台接口测试文档
+
+## 文档概述
+
+本文档详细描述了农业管理平台中种植计划和灌溉测试模块的8个RESTful接口,包括接口功能、请求参数、响应格式和使用示例。
+
+---
+
+## 一、接口总览
+
+| 模块 | 接口名称 | 请求方法 | 接口地址 | 功能描述 |
+|------|----------|----------|----------|----------|
+| 种植计划 | 创建种植计划 | POST | `/plantplan/add` | 添加新的种植计划记录 |
+| 种植计划 | 查询种植计划 | GET | `/plantplan/get` | 分页查询种植计划列表 |
+| 种植计划 | 更新种植计划 | PUT | `/plantplan/modify` | 修改指定种植计划信息 |
+| 种植计划 | 删除种植计划 | DELETE | `/plantplan/delete/{id}` | 删除指定的种植计划 |
+| 灌溉测试 | 创建灌溉测试 | POST | `/irrigationtest/add` | 添加新的灌溉测试记录 |
+| 灌溉测试 | 查询灌溉测试 | GET | `/irrigationtest/get` | 分页查询灌溉测试列表 |
+| 灌溉测试 | 更新灌溉测试 | PUT | `/irrigationtest/modify` | 修改指定灌溉测试信息 |
+| 灌溉测试 | 删除灌溉测试 | DELETE | `/irrigationtest/delete/{id}` | 删除指定的灌溉测试 |
+
+---
+
+## 二、接口详情
+
+### 2.1 种植计划模块
+
+#### 接口1:创建种植计划
+
+**请求信息**
+- **URL**: `http://101.201.78.54:5000/plantplan/add`
+- **Method**: POST
+- **Content-Type**: `application/json; charset=utf-8`
+
+**请求参数**
+```json
+{
+  "farming_type": "string",       // 种植类型,如:"水稻种植"
+  "variety": "string",            // 品种,如:"南粳46"
+  "target_yield": "float",        // 目标产量
+  "rice_type": "string",          // 水稻类型,可选
+  "planting_method": "string",    // 种植方法,如:"机插"
+  "sowing_date": "string",        // 播种日期,格式:"YYYY-MM-DD"
+  "transplanting_date": "string"  // 移栽日期,格式:"YYYY-MM-DD",可选
+}
+```
+
+**响应示例**
+```json
+{
+  "code": 200,
+  "message": "创建成功",
+  "data": {
+    "id": 12345,
+    "farming_type": "水稻种植",
+    "variety": "南粳46",
+    "target_yield": 1500.5,
+    "rice_type": "粳稻",
+    "planting_method": "机插",
+    "sowing_date": "2024-03-15",
+    "transplanting_date": "2024-04-10",
+    "create_time": "2024-03-10T10:30:00.000Z"
+  }
+}
+```
+
+#### 接口2:查询种植计划
+
+**请求信息**
+- **URL**: `http://101.201.78.54:5000/plantplan/get`
+- **Method**: GET
+- **Content-Type**: `application/json; charset=utf-8`
+
+**请求参数**
+| 参数名 | 类型 | 必填 | 说明 |
+|--------|------|------|------|
+| `page` | integer | 否 | 页码,默认:1 |
+| `per_page` | integer | 否 | 每页条数,默认:10 |
+| `farming_type` | string | 否 | 种植类型筛选 |
+| `variety` | string | 否 | 品种筛选 |
+| `rice_type` | string | 否 | 水稻类型筛选 |
+| `planting_method` | string | 否 | 种植方法筛选 |
+
+**响应示例**
+```json
+{
+  "code": 200,
+  "message": "查询成功",
+  "data": {
+    "items": [
+      {
+        "id": 12345,
+        "farming_type": "水稻种植",
+        "variety": "南粳46",
+        "target_yield": 1500.5,
+        "rice_type": "粳稻",
+        "planting_method": "机插",
+        "sowing_date": "2024-03-15",
+        "transplanting_date": "2024-04-10",
+        "create_time": "2024-03-10T10:30:00.000Z"
+      }
+    ],
+    "total": 100,
+    "page": 1,
+    "per_page": 10,
+    "total_pages": 10
+  }
+}
+```
+
+#### 接口3:更新种植计划
+
+**请求信息**
+- **URL**: `http://101.201.78.54:5000/plantplan/modify`
+- **Method**: PUT
+- **Content-Type**: `application/json; charset=utf-8`
+
+**请求参数**
+```json
+{
+  "id": "integer",                // 必填,种植计划ID
+  "target_yield": "float",        // 可选,目标产量
+  "planting_method": "string",    // 可选,种植方法
+  "sowing_date": "string",        // 可选,播种日期
+  "transplanting_date": "string", // 可选,移栽日期
+  "rice_type": "string"           // 可选,水稻类型
+}
+```
+
+**响应示例**
+```json
+{
+  "code": 200,
+  "message": "更新成功",
+  "data": {
+    "id": 12345,
+    "updated_fields": ["target_yield", "planting_method"]
+  }
+}
+```
+
+#### 接口4:删除种植计划
+
+**请求信息**
+- **URL**: `http://101.201.78.54:5000/plantplan/delete/{id}`
+- **Method**: DELETE
+- **Path Parameter**: `id` - 种植计划ID
+
+**请求示例**
+```
+DELETE /plantplan/delete/12345
+```
+
+**响应示例**
+```json
+{
+  "code": 200,
+  "message": "删除成功",
+  "data": {
+    "id": 12345,
+    "deleted": true
+  }
+}
+```
+
+### 2.2 灌溉测试模块
+
+#### 接口5:创建灌溉测试
+
+**请求信息**
+- **URL**: `http://101.201.78.54:5000/irrigationtest/add`
+- **Method**: POST
+- **Content-Type**: `application/json; charset=utf-8`
+
+**请求参数**
+```json
+{
+  "test_name": "string",          // 测试名称,如:"测试_灌溉_abc123"
+  "plant_name": "string",         // 植物名称,如:"南粳46"
+  "plant_model": "string",        // 植物模型,如:"机插"
+  "plant_time": "string",         // 种植时间,格式:"YYYY-MM-DDTHH:MM:SS.sssZ"
+  "cultivation_time": "string",   // 培育时间,格式:"YYYY-MM-DDTHH:MM:SS.sssZ"
+  "cultivation_model": "string",  // 培育模型,如:"水层栽培"
+  "farm_name": "string",          // 农场名称,如:"智慧农业基地_1001"
+  "farm_id": "integer",           // 农场ID
+  "uploader": "string",           // 上传者,如:"张三"
+  "upload_time": "string",        // 上传时间,格式:"YYYY/MM/DD HH:MM:SS"
+  "server_type": "string"         // 服务器类型,如:"测试环境"
+}
+```
+
+**响应示例**
+```json
+{
+  "code": 200,
+  "message": "创建成功",
+  "data": {
+    "id": 67890,
+    "test_name": "测试_灌溉_abc123",
+    "plant_name": "南粳46",
+    "plant_model": "机插",
+    "farm_id": 1001,
+    "uploader": "张三",
+    "server_type": "测试环境"
+  }
+}
+```
+
+#### 接口6:查询灌溉测试
+
+**请求信息**
+- **URL**: `http://101.201.78.54:5000/irrigationtest/get`
+- **Method**: GET
+- **Content-Type**: `application/json; charset=utf-8`
+
+**请求参数**
+| 参数名 | 类型 | 必填 | 说明 |
+|--------|------|------|------|
+| `page` | integer | 否 | 页码,默认:1 |
+| `per_page` | integer | 否 | 每页条数,默认:10 |
+| `test_name` | string | 否 | 测试名称筛选 |
+| `plant_name` | string | 否 | 植物名称筛选 |
+| `farm_name` | string | 否 | 农场名称筛选 |
+| `farm_id` | integer | 否 | 农场ID筛选 |
+| `uploader` | string | 否 | 上传者筛选 |
+| `server_type` | string | 否 | 服务器类型筛选 |
+
+**响应示例**
+```json
+{
+  "code": 200,
+  "message": "查询成功",
+  "data": {
+    "items": [
+      {
+        "id": 67890,
+        "test_name": "测试_灌溉_abc123",
+        "plant_name": "南粳46",
+        "plant_model": "机插",
+        "plant_time": "2024-03-10T08:30:00.000Z",
+        "cultivation_time": "2024-03-15T10:00:00.000Z",
+        "cultivation_model": "水层栽培",
+        "farm_name": "智慧农业基地_1001",
+        "farm_id": 1001,
+        "uploader": "张三",
+        "upload_time": "2024/03/10 14:30:00",
+        "server_type": "测试环境",
+        "create_time": "2024-03-10T14:30:00.000Z"
+      }
+    ],
+    "total": 50,
+    "page": 1,
+    "per_page": 10,
+    "total_pages": 5
+  }
+}
+```
+
+#### 接口7:更新灌溉测试
+
+**请求信息**
+- **URL**: `http://101.201.78.54:5000/irrigationtest/modify`
+- **Method**: PUT
+- **Content-Type**: `application/json; charset=utf-8`
+
+**请求参数**
+```json
+{
+  "id": "integer",                // 必填,灌溉测试ID
+  "test_name": "string",          // 可选,测试名称
+  "server_type": "string",        // 可选,服务器类型
+  "plant_time": "string",         // 可选,种植时间
+  "upload_time": "string",        // 可选,上传时间
+  "uploader": "string",           // 可选,上传者
+  "farm_name": "string"           // 可选,农场名称
+}
+```
+
+**响应示例**
+```json
+{
+  "code": 200,
+  "message": "更新成功",
+  "data": {
+    "id": 67890,
+    "updated_fields": ["test_name", "server_type", "upload_time"]
+  }
+}
+```
+
+#### 接口8:删除灌溉测试
+
+**请求信息**
+- **URL**: `http://101.201.78.54:5000/irrigationtest/delete/{id}`
+- **Method**: DELETE
+- **Path Parameter**: `id` - 灌溉测试ID
+
+**请求示例**
+```
+DELETE /irrigationtest/delete/67890
+```
+
+**响应示例**
+```json
+{
+  "code": 200,
+  "message": "删除成功",
+  "data": {
+    "id": 67890,
+    "deleted": true
+  }
+}
+```
+
+---
+
+## 三、通用响应格式
+
+所有接口遵循统一的响应格式:
+
+```json
+{
+  "code": number,      // 状态码:200-成功,400-客户端错误,500-服务器错误
+  "message": "string", // 响应消息
+  "data": object/null  // 响应数据,可为空
+}
+```
+
+**状态码说明**
+- `200`: 请求成功
+- `400`: 请求参数错误
+- `401`: 未授权访问
+- `404`: 资源不存在
+- `500`: 服务器内部错误