POST /api/v1/plants
请求体
{
"name": "我的龟背竹",
"speciesId": 1,
"locationId": 1,
"plantingDate": "2026-03-15",
"cultivationMethod": 1,
"substrate": 1,
"status": 1,
"remark": "朋友送的礼物",
"covers": [
300,
301
],
"tagIds": [1, 3]
}
| 字段 | 类型 | 必填 | 约束 | 说明 |
|---|---|---|---|---|
name |
string |
是 | 1-48 字符 | 植物名称 |
speciesId |
number |
是 | — | 植物种类 ID |
locationId |
number |
是 | — | 所在位置 ID |
plantingDate |
string |
否 | YYYY-MM-DD | 种植日期 |
cultivationMethod |
number |
否 | 见 CultivationMethod 枚举 | 种植方式 |
substrate |
number |
否 | 见 Substrate 枚举 | 栽培介质 |
status |
number |
否 | 0-2,见 PlantStatus 枚举 | 植物状态 |
remark |
string |
否 | — | 备注 |
covers |
array |
否 | — | 封面 mediaId 列表,位置即顺序(重复/空值自动忽略) |
tagIds |
array |
否 | — | 标签 ID 列表 |
响应
{
"code": 200,
"message": "success",
"data": {
"id": 1,
"name": "我的龟背竹",
"species": { "id": 1, "commonName": "龟背竹", "scientificName": "Monstera deliciosa" },
"location": { "id": 1, "name": "花架上层" },
"plantingDate": "2026-03-15",
"cultivationMethod": 1,
"substrate": 1,
"status": 1,
"remark": "朋友送的礼物",
"covers": [
{
"id": 300,
"url": "https://cdn.floriax.cn/media/1/2026/05/14/uuid1.jpg"
},
{
"id": 301,
"url": "https://cdn.floriax.cn/media/1/2026/05/14/uuid2.jpg"
}
],
"tags": [
{ "id": 1, "name": "室内" },
{ "id": 3, "name": "观叶" }
],
"createdAt": 1747123456789
},
"requestId": "...",
"timestamp": 1747123456789
}
| 字段 | 类型 | 说明 |
|---|---|---|
id |
number |
植物 ID |
name |
string |
植物名称 |
species |
object |
种类摘要 { id, commonName, scientificName };可为 null —— 当关联的种类被删除时返回 null |
location |
object |
所在位置(含 id、name);可为 null —— 当植物关联的位置被删除后,植物进入"无位置"态,location 返回 null |
plantingDate |
string |
种植日期(YYYY-MM-DD) |
cultivationMethod |
number |
种植方式 |
substrate |
number |
栽培介质,见 Substrate 枚举 |
status |
number |
植物状态,见 PlantStatus 枚举 |
remark |
string |
备注,未设置时不出现此字段 |
covers |
array |
封面图列表,按排序号升序,每项为 MediaSummary(id、url) |
tags |
array |
标签列表,每项含 id、name |
createdAt |
number |
建档时间(epoch 毫秒) |