增加设备模板列表

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

@@ -213,6 +213,204 @@ const docTemplate = `{
}
}
},
"/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": "获取系统中所有设备的列表",
@@ -960,6 +1158,74 @@ const docTemplate = `{
}
}
},
"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": [
@@ -1008,6 +1274,38 @@ const docTemplate = `{
}
}
},
"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": {
@@ -1044,6 +1342,17 @@ const docTemplate = `{
}
}
},
"models.DeviceCategory": {
"type": "string",
"enum": [
"actuator",
"sensor"
],
"x-enum-varnames": [
"CategoryActuator",
"CategorySensor"
]
},
"models.PlanContentType": {
"type": "string",
"enum": [
@@ -1110,6 +1419,37 @@ const docTemplate = `{
"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": [
@@ -1133,6 +1473,22 @@ const docTemplate = `{
"TaskTypeReleaseFeedWeight"
]
},
"models.ValueDescriptor": {
"type": "object",
"properties": {
"multiplier": {
"description": "乘数,用于原始数据转换",
"type": "number"
},
"offset": {
"description": "偏移量,用于原始数据转换",
"type": "number"
},
"type": {
"$ref": "#/definitions/models.SensorType"
}
}
},
"plan.CreatePlanRequest": {
"type": "object",
"required": [

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": [

View File

@@ -102,6 +102,52 @@ definitions:
- device_template_id
- name
type: object
device.CreateDeviceTemplateRequest:
properties:
category:
$ref: '#/definitions/models.DeviceCategory'
commands:
additionalProperties: true
type: object
description:
type: string
manufacturer:
type: string
name:
type: string
values:
items:
$ref: '#/definitions/models.ValueDescriptor'
type: array
required:
- category
- commands
- name
type: object
device.DeviceTemplateResponse:
properties:
category:
$ref: '#/definitions/models.DeviceCategory'
commands:
additionalProperties: true
type: object
created_at:
type: string
description:
type: string
id:
type: integer
manufacturer:
type: string
name:
type: string
updated_at:
type: string
values:
items:
$ref: '#/definitions/models.ValueDescriptor'
type: array
type: object
device.UpdateAreaControllerRequest:
properties:
location:
@@ -135,6 +181,28 @@ definitions:
- device_template_id
- name
type: object
device.UpdateDeviceTemplateRequest:
properties:
category:
$ref: '#/definitions/models.DeviceCategory'
commands:
additionalProperties: true
type: object
description:
type: string
manufacturer:
type: string
name:
type: string
values:
items:
$ref: '#/definitions/models.ValueDescriptor'
type: array
required:
- category
- commands
- name
type: object
git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse:
properties:
area_controller_id:
@@ -159,6 +227,14 @@ definitions:
updated_at:
type: string
type: object
models.DeviceCategory:
enum:
- actuator
- sensor
type: string
x-enum-varnames:
- CategoryActuator
- CategorySensor
models.PlanContentType:
enum:
- sub_plans
@@ -210,6 +286,32 @@ definitions:
- PlanStatusEnabled
- PlanStatusStopeed
- PlanStatusFailed
models.SensorType:
enum:
- signal_metrics
- battery_level
- temperature
- humidity
- weight
type: string
x-enum-comments:
SensorTypeBatteryLevel: 电池电量
SensorTypeHumidity: 湿度
SensorTypeSignalMetrics: 信号强度
SensorTypeTemperature: 温度
SensorTypeWeight: 重量
x-enum-descriptions:
- 信号强度
- 电池电量
- 温度
- 湿度
- 重量
x-enum-varnames:
- SensorTypeSignalMetrics
- SensorTypeBatteryLevel
- SensorTypeTemperature
- SensorTypeHumidity
- SensorTypeWeight
models.TaskType:
enum:
- plan_analysis
@@ -228,6 +330,17 @@ definitions:
- TaskPlanAnalysis
- TaskTypeWaiting
- TaskTypeReleaseFeedWeight
models.ValueDescriptor:
properties:
multiplier:
description: 乘数,用于原始数据转换
type: number
offset:
description: 偏移量,用于原始数据转换
type: number
type:
$ref: '#/definitions/models.SensorType'
type: object
plan.CreatePlanRequest:
properties:
cron_expression:
@@ -594,6 +707,125 @@ paths:
summary: 更新区域主控信息
tags:
- 区域主控管理
/api/v1/device-templates:
get:
description: 获取系统中所有设备模板的列表
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
items:
$ref: '#/definitions/device.DeviceTemplateResponse'
type: array
type: object
summary: 获取设备模板列表
tags:
- 设备模板管理
post:
consumes:
- application/json
description: 根据提供的信息创建一个新设备模板
parameters:
- description: 设备模板信息
in: body
name: deviceTemplate
required: true
schema:
$ref: '#/definitions/device.CreateDeviceTemplateRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/device.DeviceTemplateResponse'
type: object
summary: 创建新设备模板
tags:
- 设备模板管理
/api/v1/device-templates/{id}:
delete:
description: 根据设备模板ID删除一个设备模板软删除
parameters:
- description: 设备模板ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/controller.Response'
summary: 删除设备模板
tags:
- 设备模板管理
get:
description: 根据设备模板ID获取单个设备模板的详细信息
parameters:
- description: 设备模板ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/device.DeviceTemplateResponse'
type: object
summary: 获取设备模板信息
tags:
- 设备模板管理
put:
consumes:
- application/json
description: 根据设备模板ID更新一个已存在的设备模板信息
parameters:
- description: 设备模板ID
in: path
name: id
required: true
type: string
- description: 要更新的设备模板信息
in: body
name: deviceTemplate
required: true
schema:
$ref: '#/definitions/device.UpdateDeviceTemplateRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/device.DeviceTemplateResponse'
type: object
summary: 更新设备模板信息
tags:
- 设备模板管理
/api/v1/devices:
get:
description: 获取系统中所有设备的列表