This commit is contained in:
2025-09-14 21:30:20 +08:00
parent 784b02b571
commit 6dc6fc427c
3 changed files with 634 additions and 0 deletions

View File

@@ -550,19 +550,106 @@ const docTemplate = `{
"DeviceTypeDevice"
]
},
"models.PlanContentType": {
"type": "string",
"enum": [
"sub_plans",
"tasks"
],
"x-enum-comments": {
"PlanContentTypeSubPlans": "计划包含子计划",
"PlanContentTypeTasks": "计划包含任务"
},
"x-enum-descriptions": [
"计划包含子计划",
"计划包含任务"
],
"x-enum-varnames": [
"PlanContentTypeSubPlans",
"PlanContentTypeTasks"
]
},
"models.PlanExecutionType": {
"type": "string",
"enum": [
"automatic",
"manual"
],
"x-enum-comments": {
"PlanExecutionTypeAutomatic": "自动执行 (包含定时和循环)",
"PlanExecutionTypeManual": "手动执行"
},
"x-enum-descriptions": [
"自动执行 (包含定时和循环)",
"手动执行"
],
"x-enum-varnames": [
"PlanExecutionTypeAutomatic",
"PlanExecutionTypeManual"
]
},
"models.TaskType": {
"type": "string",
"enum": [
"waiting"
],
"x-enum-comments": {
"TaskTypeWaiting": "等待任务"
},
"x-enum-descriptions": [
"等待任务"
],
"x-enum-varnames": [
"TaskTypeWaiting"
]
},
"plan.CreatePlanRequest": {
"type": "object",
"required": [
"content_type",
"execution_type",
"name"
],
"properties": {
"content_type": {
"allOf": [
{
"$ref": "#/definitions/models.PlanContentType"
}
],
"example": "tasks"
},
"cron_expression": {
"type": "string",
"example": "0 0 6 * * *"
},
"description": {
"type": "string",
"example": "根据温度自动调节风扇和加热器"
},
"execution_type": {
"allOf": [
{
"$ref": "#/definitions/models.PlanExecutionType"
}
],
"example": "automatic"
},
"name": {
"type": "string",
"example": "猪舍温度控制计划"
},
"sub_plan_ids": {
"type": "array",
"items": {
"type": "integer"
}
},
"tasks": {
"type": "array",
"items": {
"$ref": "#/definitions/plan.TaskRequest"
}
}
}
},
@@ -584,10 +671,30 @@ const docTemplate = `{
"plan.PlanResponse": {
"type": "object",
"properties": {
"content_type": {
"allOf": [
{
"$ref": "#/definitions/models.PlanContentType"
}
],
"example": "tasks"
},
"cron_expression": {
"type": "string",
"example": "0 0 6 * * *"
},
"description": {
"type": "string",
"example": "根据温度自动调节风扇和加热器"
},
"execution_type": {
"allOf": [
{
"$ref": "#/definitions/models.PlanExecutionType"
}
],
"example": "automatic"
},
"id": {
"type": "integer",
"example": 1
@@ -595,19 +702,151 @@ const docTemplate = `{
"name": {
"type": "string",
"example": "猪舍温度控制计划"
},
"sub_plans": {
"type": "array",
"items": {
"$ref": "#/definitions/plan.SubPlanResponse"
}
},
"tasks": {
"type": "array",
"items": {
"$ref": "#/definitions/plan.TaskResponse"
}
}
}
},
"plan.SubPlanResponse": {
"type": "object",
"properties": {
"child_plan": {
"$ref": "#/definitions/plan.PlanResponse"
},
"child_plan_id": {
"type": "integer",
"example": 2
},
"execution_order": {
"type": "integer",
"example": 1
},
"id": {
"type": "integer",
"example": 1
},
"parent_plan_id": {
"type": "integer",
"example": 1
}
}
},
"plan.TaskRequest": {
"type": "object",
"properties": {
"description": {
"type": "string",
"example": "打开1号风扇"
},
"execution_order": {
"type": "integer",
"example": 1
},
"name": {
"type": "string",
"example": "打开风扇"
},
"parameters": {
"$ref": "#/definitions/controller.Properties"
},
"type": {
"allOf": [
{
"$ref": "#/definitions/models.TaskType"
}
],
"example": "waiting"
}
}
},
"plan.TaskResponse": {
"type": "object",
"properties": {
"description": {
"type": "string",
"example": "打开1号风扇"
},
"execution_order": {
"type": "integer",
"example": 1
},
"id": {
"type": "integer",
"example": 1
},
"name": {
"type": "string",
"example": "打开风扇"
},
"parameters": {
"$ref": "#/definitions/controller.Properties"
},
"plan_id": {
"type": "integer",
"example": 1
},
"type": {
"allOf": [
{
"$ref": "#/definitions/models.TaskType"
}
],
"example": "waiting"
}
}
},
"plan.UpdatePlanRequest": {
"type": "object",
"properties": {
"content_type": {
"allOf": [
{
"$ref": "#/definitions/models.PlanContentType"
}
],
"example": "tasks"
},
"cron_expression": {
"type": "string",
"example": "0 0 6 * * *"
},
"description": {
"type": "string",
"example": "更新后的描述"
},
"execution_type": {
"allOf": [
{
"$ref": "#/definitions/models.PlanExecutionType"
}
],
"example": "automatic"
},
"name": {
"type": "string",
"example": "猪舍温度控制计划V2"
},
"sub_plan_ids": {
"type": "array",
"items": {
"type": "integer"
}
},
"tasks": {
"type": "array",
"items": {
"$ref": "#/definitions/plan.TaskRequest"
}
}
}
},