From 6dc6fc427cba8c36a8917b72a08ced992478fec6 Mon Sep 17 00:00:00 2001 From: huang <1724659546@qq.com> Date: Sun, 14 Sep 2025 21:30:20 +0800 Subject: [PATCH] swag --- docs/docs.go | 239 ++++++++++++++++++++++++++++++++++++++++++++++ docs/swagger.json | 239 ++++++++++++++++++++++++++++++++++++++++++++++ docs/swagger.yaml | 156 ++++++++++++++++++++++++++++++ 3 files changed, 634 insertions(+) diff --git a/docs/docs.go b/docs/docs.go index ac1f905..9d484ed 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -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" + } } } }, diff --git a/docs/swagger.json b/docs/swagger.json index 05502ad..a8eb9a8 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -539,19 +539,106 @@ "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" + } } } }, @@ -573,10 +660,30 @@ "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 @@ -584,19 +691,151 @@ "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" + } } } }, diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 685ec6a..3f48976 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -79,15 +79,74 @@ definitions: x-enum-varnames: - DeviceTypeAreaController - DeviceTypeDevice + models.PlanContentType: + enum: + - sub_plans + - tasks + type: string + x-enum-comments: + PlanContentTypeSubPlans: 计划包含子计划 + PlanContentTypeTasks: 计划包含任务 + x-enum-descriptions: + - 计划包含子计划 + - 计划包含任务 + x-enum-varnames: + - PlanContentTypeSubPlans + - PlanContentTypeTasks + models.PlanExecutionType: + enum: + - automatic + - manual + type: string + x-enum-comments: + PlanExecutionTypeAutomatic: 自动执行 (包含定时和循环) + PlanExecutionTypeManual: 手动执行 + x-enum-descriptions: + - 自动执行 (包含定时和循环) + - 手动执行 + x-enum-varnames: + - PlanExecutionTypeAutomatic + - PlanExecutionTypeManual + models.TaskType: + enum: + - waiting + type: string + x-enum-comments: + TaskTypeWaiting: 等待任务 + x-enum-descriptions: + - 等待任务 + x-enum-varnames: + - TaskTypeWaiting plan.CreatePlanRequest: properties: + content_type: + allOf: + - $ref: '#/definitions/models.PlanContentType' + example: tasks + cron_expression: + example: 0 0 6 * * * + type: string description: example: 根据温度自动调节风扇和加热器 type: string + execution_type: + allOf: + - $ref: '#/definitions/models.PlanExecutionType' + example: automatic name: example: 猪舍温度控制计划 type: string + sub_plan_ids: + items: + type: integer + type: array + tasks: + items: + $ref: '#/definitions/plan.TaskRequest' + type: array required: + - content_type + - execution_type - name type: object plan.ListPlansResponse: @@ -102,24 +161,121 @@ definitions: type: object plan.PlanResponse: properties: + content_type: + allOf: + - $ref: '#/definitions/models.PlanContentType' + example: tasks + cron_expression: + example: 0 0 6 * * * + type: string description: example: 根据温度自动调节风扇和加热器 type: string + execution_type: + allOf: + - $ref: '#/definitions/models.PlanExecutionType' + example: automatic id: example: 1 type: integer name: example: 猪舍温度控制计划 type: string + sub_plans: + items: + $ref: '#/definitions/plan.SubPlanResponse' + type: array + tasks: + items: + $ref: '#/definitions/plan.TaskResponse' + type: array + type: object + plan.SubPlanResponse: + properties: + child_plan: + $ref: '#/definitions/plan.PlanResponse' + child_plan_id: + example: 2 + type: integer + execution_order: + example: 1 + type: integer + id: + example: 1 + type: integer + parent_plan_id: + example: 1 + type: integer + type: object + plan.TaskRequest: + properties: + description: + example: 打开1号风扇 + type: string + execution_order: + example: 1 + type: integer + name: + example: 打开风扇 + type: string + parameters: + $ref: '#/definitions/controller.Properties' + type: + allOf: + - $ref: '#/definitions/models.TaskType' + example: waiting + type: object + plan.TaskResponse: + properties: + description: + example: 打开1号风扇 + type: string + execution_order: + example: 1 + type: integer + id: + example: 1 + type: integer + name: + example: 打开风扇 + type: string + parameters: + $ref: '#/definitions/controller.Properties' + plan_id: + example: 1 + type: integer + type: + allOf: + - $ref: '#/definitions/models.TaskType' + example: waiting type: object plan.UpdatePlanRequest: properties: + content_type: + allOf: + - $ref: '#/definitions/models.PlanContentType' + example: tasks + cron_expression: + example: 0 0 6 * * * + type: string description: example: 更新后的描述 type: string + execution_type: + allOf: + - $ref: '#/definitions/models.PlanExecutionType' + example: automatic name: example: 猪舍温度控制计划V2 type: string + sub_plan_ids: + items: + type: integer + type: array + tasks: + items: + $ref: '#/definitions/plan.TaskRequest' + type: array type: object user.CreateUserRequest: properties: