修改api接口定义

This commit is contained in:
2025-09-19 13:18:05 +08:00
parent d94a18779e
commit 11502cb5f0
5 changed files with 202 additions and 75 deletions

View File

@@ -459,7 +459,34 @@ const docTemplate = `{
"device.CreateDeviceRequest": { "device.CreateDeviceRequest": {
"type": "object" "type": "object"
}, },
"device.DeviceResponse": { "device.UpdateDeviceRequest": {
"type": "object",
"required": [
"name",
"type"
],
"properties": {
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"parent_id": {
"type": "integer"
},
"properties": {
"$ref": "#/definitions/controller.Properties"
},
"sub_type": {
"$ref": "#/definitions/models.DeviceSubType"
},
"type": {
"$ref": "#/definitions/models.DeviceType"
}
}
},
"git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"created_at": { "created_at": {
@@ -491,33 +518,6 @@ const docTemplate = `{
} }
} }
}, },
"device.UpdateDeviceRequest": {
"type": "object",
"required": [
"name",
"type"
],
"properties": {
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"parent_id": {
"type": "integer"
},
"properties": {
"$ref": "#/definitions/controller.Properties"
},
"sub_type": {
"$ref": "#/definitions/models.DeviceSubType"
},
"type": {
"$ref": "#/definitions/models.DeviceType"
}
}
},
"models.DeviceSubType": { "models.DeviceSubType": {
"type": "string", "type": "string",
"enum": [ "enum": [
@@ -588,18 +588,46 @@ const docTemplate = `{
"PlanExecutionTypeManual" "PlanExecutionTypeManual"
] ]
}, },
"models.PlanStatus": {
"type": "integer",
"format": "int32",
"enum": [
0,
1,
2
],
"x-enum-comments": {
"PlanStatusDisabled": "禁用计划",
"PlanStatusEnabled": "启用计划",
"PlanStatusStopeed": "执行完毕"
},
"x-enum-descriptions": [
"启用计划",
"禁用计划",
"执行完毕"
],
"x-enum-varnames": [
"PlanStatusEnabled",
"PlanStatusDisabled",
"PlanStatusStopeed"
]
},
"models.TaskType": { "models.TaskType": {
"type": "string", "type": "string",
"enum": [ "enum": [
"plan_analysis",
"waiting" "waiting"
], ],
"x-enum-comments": { "x-enum-comments": {
"TaskPlanAnalysis": "解析Plan的Task列表并添加到待执行队列的特殊任务",
"TaskTypeWaiting": "等待任务" "TaskTypeWaiting": "等待任务"
}, },
"x-enum-descriptions": [ "x-enum-descriptions": [
"解析Plan的Task列表并添加到待执行队列的特殊任务",
"等待任务" "等待任务"
], ],
"x-enum-varnames": [ "x-enum-varnames": [
"TaskPlanAnalysis",
"TaskTypeWaiting" "TaskTypeWaiting"
] ]
}, },
@@ -687,6 +715,14 @@ const docTemplate = `{
"type": "string", "type": "string",
"example": "根据温度自动调节风扇和加热器" "example": "根据温度自动调节风扇和加热器"
}, },
"execute_count": {
"type": "integer",
"example": 0
},
"execute_num": {
"type": "integer",
"example": 10
},
"execution_type": { "execution_type": {
"allOf": [ "allOf": [
{ {
@@ -703,6 +739,14 @@ const docTemplate = `{
"type": "string", "type": "string",
"example": "猪舍温度控制计划" "example": "猪舍温度控制计划"
}, },
"status": {
"allOf": [
{
"$ref": "#/definitions/models.PlanStatus"
}
],
"example": 0
},
"sub_plans": { "sub_plans": {
"type": "array", "type": "array",
"items": { "items": {

View File

@@ -448,7 +448,34 @@
"device.CreateDeviceRequest": { "device.CreateDeviceRequest": {
"type": "object" "type": "object"
}, },
"device.DeviceResponse": { "device.UpdateDeviceRequest": {
"type": "object",
"required": [
"name",
"type"
],
"properties": {
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"parent_id": {
"type": "integer"
},
"properties": {
"$ref": "#/definitions/controller.Properties"
},
"sub_type": {
"$ref": "#/definitions/models.DeviceSubType"
},
"type": {
"$ref": "#/definitions/models.DeviceType"
}
}
},
"git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse": {
"type": "object", "type": "object",
"properties": { "properties": {
"created_at": { "created_at": {
@@ -480,33 +507,6 @@
} }
} }
}, },
"device.UpdateDeviceRequest": {
"type": "object",
"required": [
"name",
"type"
],
"properties": {
"location": {
"type": "string"
},
"name": {
"type": "string"
},
"parent_id": {
"type": "integer"
},
"properties": {
"$ref": "#/definitions/controller.Properties"
},
"sub_type": {
"$ref": "#/definitions/models.DeviceSubType"
},
"type": {
"$ref": "#/definitions/models.DeviceType"
}
}
},
"models.DeviceSubType": { "models.DeviceSubType": {
"type": "string", "type": "string",
"enum": [ "enum": [
@@ -577,18 +577,46 @@
"PlanExecutionTypeManual" "PlanExecutionTypeManual"
] ]
}, },
"models.PlanStatus": {
"type": "integer",
"format": "int32",
"enum": [
0,
1,
2
],
"x-enum-comments": {
"PlanStatusDisabled": "禁用计划",
"PlanStatusEnabled": "启用计划",
"PlanStatusStopeed": "执行完毕"
},
"x-enum-descriptions": [
"启用计划",
"禁用计划",
"执行完毕"
],
"x-enum-varnames": [
"PlanStatusEnabled",
"PlanStatusDisabled",
"PlanStatusStopeed"
]
},
"models.TaskType": { "models.TaskType": {
"type": "string", "type": "string",
"enum": [ "enum": [
"plan_analysis",
"waiting" "waiting"
], ],
"x-enum-comments": { "x-enum-comments": {
"TaskPlanAnalysis": "解析Plan的Task列表并添加到待执行队列的特殊任务",
"TaskTypeWaiting": "等待任务" "TaskTypeWaiting": "等待任务"
}, },
"x-enum-descriptions": [ "x-enum-descriptions": [
"解析Plan的Task列表并添加到待执行队列的特殊任务",
"等待任务" "等待任务"
], ],
"x-enum-varnames": [ "x-enum-varnames": [
"TaskPlanAnalysis",
"TaskTypeWaiting" "TaskTypeWaiting"
] ]
}, },
@@ -676,6 +704,14 @@
"type": "string", "type": "string",
"example": "根据温度自动调节风扇和加热器" "example": "根据温度自动调节风扇和加热器"
}, },
"execute_count": {
"type": "integer",
"example": 0
},
"execute_num": {
"type": "integer",
"example": 10
},
"execution_type": { "execution_type": {
"allOf": [ "allOf": [
{ {
@@ -692,6 +728,14 @@
"type": "string", "type": "string",
"example": "猪舍温度控制计划" "example": "猪舍温度控制计划"
}, },
"status": {
"allOf": [
{
"$ref": "#/definitions/models.PlanStatus"
}
],
"example": 0
},
"sub_plans": { "sub_plans": {
"type": "array", "type": "array",
"items": { "items": {

View File

@@ -14,7 +14,25 @@ definitions:
type: object type: object
device.CreateDeviceRequest: device.CreateDeviceRequest:
type: object type: object
device.DeviceResponse: device.UpdateDeviceRequest:
properties:
location:
type: string
name:
type: string
parent_id:
type: integer
properties:
$ref: '#/definitions/controller.Properties'
sub_type:
$ref: '#/definitions/models.DeviceSubType'
type:
$ref: '#/definitions/models.DeviceType'
required:
- name
- type
type: object
git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse:
properties: properties:
created_at: created_at:
type: string type: string
@@ -35,24 +53,6 @@ definitions:
updated_at: updated_at:
type: string type: string
type: object type: object
device.UpdateDeviceRequest:
properties:
location:
type: string
name:
type: string
parent_id:
type: integer
properties:
$ref: '#/definitions/controller.Properties'
sub_type:
$ref: '#/definitions/models.DeviceSubType'
type:
$ref: '#/definitions/models.DeviceType'
required:
- name
- type
type: object
models.DeviceSubType: models.DeviceSubType:
enum: enum:
- "" - ""
@@ -107,15 +107,38 @@ definitions:
x-enum-varnames: x-enum-varnames:
- PlanExecutionTypeAutomatic - PlanExecutionTypeAutomatic
- PlanExecutionTypeManual - PlanExecutionTypeManual
models.PlanStatus:
enum:
- 0
- 1
- 2
format: int32
type: integer
x-enum-comments:
PlanStatusDisabled: 禁用计划
PlanStatusEnabled: 启用计划
PlanStatusStopeed: 执行完毕
x-enum-descriptions:
- 启用计划
- 禁用计划
- 执行完毕
x-enum-varnames:
- PlanStatusEnabled
- PlanStatusDisabled
- PlanStatusStopeed
models.TaskType: models.TaskType:
enum: enum:
- plan_analysis
- waiting - waiting
type: string type: string
x-enum-comments: x-enum-comments:
TaskPlanAnalysis: 解析Plan的Task列表并添加到待执行队列的特殊任务
TaskTypeWaiting: 等待任务 TaskTypeWaiting: 等待任务
x-enum-descriptions: x-enum-descriptions:
- 解析Plan的Task列表并添加到待执行队列的特殊任务
- 等待任务 - 等待任务
x-enum-varnames: x-enum-varnames:
- TaskPlanAnalysis
- TaskTypeWaiting - TaskTypeWaiting
plan.CreatePlanRequest: plan.CreatePlanRequest:
properties: properties:
@@ -171,6 +194,12 @@ definitions:
description: description:
example: 根据温度自动调节风扇和加热器 example: 根据温度自动调节风扇和加热器
type: string type: string
execute_count:
example: 0
type: integer
execute_num:
example: 10
type: integer
execution_type: execution_type:
allOf: allOf:
- $ref: '#/definitions/models.PlanExecutionType' - $ref: '#/definitions/models.PlanExecutionType'
@@ -181,6 +210,10 @@ definitions:
name: name:
example: 猪舍温度控制计划 example: 猪舍温度控制计划
type: string type: string
status:
allOf:
- $ref: '#/definitions/models.PlanStatus'
example: 0
sub_plans: sub_plans:
items: items:
$ref: '#/definitions/plan.SubPlanResponse' $ref: '#/definitions/plan.SubPlanResponse'

View File

@@ -17,6 +17,9 @@ func PlanToResponse(plan *models.Plan) *PlanResponse {
Name: plan.Name, Name: plan.Name,
Description: plan.Description, Description: plan.Description,
ExecutionType: plan.ExecutionType, ExecutionType: plan.ExecutionType,
Status: plan.Status,
ExecuteNum: plan.ExecuteNum,
ExecuteCount: plan.ExecuteCount,
CronExpression: plan.CronExpression, CronExpression: plan.CronExpression,
ContentType: plan.ContentType, ContentType: plan.ContentType,
} }

View File

@@ -32,6 +32,9 @@ type PlanResponse struct {
Name string `json:"name" example:"猪舍温度控制计划"` Name string `json:"name" example:"猪舍温度控制计划"`
Description string `json:"description" example:"根据温度自动调节风扇和加热器"` Description string `json:"description" example:"根据温度自动调节风扇和加热器"`
ExecutionType models.PlanExecutionType `json:"execution_type" example:"automatic"` ExecutionType models.PlanExecutionType `json:"execution_type" example:"automatic"`
Status models.PlanStatus `json:"status" example:"0"`
ExecuteNum uint `json:"execute_num" example:"10"`
ExecuteCount uint `json:"execute_count" example:"0"`
CronExpression string `json:"cron_expression" example:"0 0 6 * * *"` CronExpression string `json:"cron_expression" example:"0 0 6 * * *"`
ContentType models.PlanContentType `json:"content_type" example:"tasks"` ContentType models.PlanContentType `json:"content_type" example:"tasks"`
SubPlans []SubPlanResponse `json:"sub_plans,omitempty"` SubPlans []SubPlanResponse `json:"sub_plans,omitempty"`