增加设备模板列表

This commit is contained in:
2025-09-30 22:07:55 +08:00
parent 108d496346
commit 077e866915
8 changed files with 1416 additions and 1 deletions

View File

@@ -202,6 +202,204 @@
}
}
},
"/api/v1/device-templates": {
"get": {
"description": "获取系统中所有设备模板的列表",
"produces": [
"application/json"
],
"tags": [
"设备模板管理"
],
"summary": "获取设备模板列表",
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/device.DeviceTemplateResponse"
}
}
}
}
]
}
}
}
},
"post": {
"description": "根据提供的信息创建一个新设备模板",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"设备模板管理"
],
"summary": "创建新设备模板",
"parameters": [
{
"description": "设备模板信息",
"name": "deviceTemplate",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/device.CreateDeviceTemplateRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/device.DeviceTemplateResponse"
}
}
}
]
}
}
}
}
},
"/api/v1/device-templates/{id}": {
"get": {
"description": "根据设备模板ID获取单个设备模板的详细信息",
"produces": [
"application/json"
],
"tags": [
"设备模板管理"
],
"summary": "获取设备模板信息",
"parameters": [
{
"type": "string",
"description": "设备模板ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/device.DeviceTemplateResponse"
}
}
}
]
}
}
}
},
"put": {
"description": "根据设备模板ID更新一个已存在的设备模板信息",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"设备模板管理"
],
"summary": "更新设备模板信息",
"parameters": [
{
"type": "string",
"description": "设备模板ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "要更新的设备模板信息",
"name": "deviceTemplate",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/device.UpdateDeviceTemplateRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/device.DeviceTemplateResponse"
}
}
}
]
}
}
}
},
"delete": {
"description": "根据设备模板ID删除一个设备模板软删除",
"produces": [
"application/json"
],
"tags": [
"设备模板管理"
],
"summary": "删除设备模板",
"parameters": [
{
"type": "string",
"description": "设备模板ID",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/controller.Response"
}
}
}
}
},
"/api/v1/devices": {
"get": {
"description": "获取系统中所有设备的列表",
@@ -949,6 +1147,74 @@
}
}
},
"device.CreateDeviceTemplateRequest": {
"type": "object",
"required": [
"category",
"commands",
"name"
],
"properties": {
"category": {
"$ref": "#/definitions/models.DeviceCategory"
},
"commands": {
"type": "object",
"additionalProperties": true
},
"description": {
"type": "string"
},
"manufacturer": {
"type": "string"
},
"name": {
"type": "string"
},
"values": {
"type": "array",
"items": {
"$ref": "#/definitions/models.ValueDescriptor"
}
}
}
},
"device.DeviceTemplateResponse": {
"type": "object",
"properties": {
"category": {
"$ref": "#/definitions/models.DeviceCategory"
},
"commands": {
"type": "object",
"additionalProperties": true
},
"created_at": {
"type": "string"
},
"description": {
"type": "string"
},
"id": {
"type": "integer"
},
"manufacturer": {
"type": "string"
},
"name": {
"type": "string"
},
"updated_at": {
"type": "string"
},
"values": {
"type": "array",
"items": {
"$ref": "#/definitions/models.ValueDescriptor"
}
}
}
},
"device.UpdateAreaControllerRequest": {
"type": "object",
"required": [
@@ -997,6 +1263,38 @@
}
}
},
"device.UpdateDeviceTemplateRequest": {
"type": "object",
"required": [
"category",
"commands",
"name"
],
"properties": {
"category": {
"$ref": "#/definitions/models.DeviceCategory"
},
"commands": {
"type": "object",
"additionalProperties": true
},
"description": {
"type": "string"
},
"manufacturer": {
"type": "string"
},
"name": {
"type": "string"
},
"values": {
"type": "array",
"items": {
"$ref": "#/definitions/models.ValueDescriptor"
}
}
}
},
"git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse": {
"type": "object",
"properties": {
@@ -1033,6 +1331,17 @@
}
}
},
"models.DeviceCategory": {
"type": "string",
"enum": [
"actuator",
"sensor"
],
"x-enum-varnames": [
"CategoryActuator",
"CategorySensor"
]
},
"models.PlanContentType": {
"type": "string",
"enum": [
@@ -1099,6 +1408,37 @@
"PlanStatusFailed"
]
},
"models.SensorType": {
"type": "string",
"enum": [
"signal_metrics",
"battery_level",
"temperature",
"humidity",
"weight"
],
"x-enum-comments": {
"SensorTypeBatteryLevel": "电池电量",
"SensorTypeHumidity": "湿度",
"SensorTypeSignalMetrics": "信号强度",
"SensorTypeTemperature": "温度",
"SensorTypeWeight": "重量"
},
"x-enum-descriptions": [
"信号强度",
"电池电量",
"温度",
"湿度",
"重量"
],
"x-enum-varnames": [
"SensorTypeSignalMetrics",
"SensorTypeBatteryLevel",
"SensorTypeTemperature",
"SensorTypeHumidity",
"SensorTypeWeight"
]
},
"models.TaskType": {
"type": "string",
"enum": [
@@ -1122,6 +1462,22 @@
"TaskTypeReleaseFeedWeight"
]
},
"models.ValueDescriptor": {
"type": "object",
"properties": {
"multiplier": {
"description": "乘数,用于原始数据转换",
"type": "number"
},
"offset": {
"description": "偏移量,用于原始数据转换",
"type": "number"
},
"type": {
"$ref": "#/definitions/models.SensorType"
}
}
},
"plan.CreatePlanRequest": {
"type": "object",
"required": [