定义控制器和注册路由(服务层和领域层没实现)

This commit is contained in:
2025-12-05 16:08:06 +08:00
parent 7017ffa128
commit 2bb187071f
9 changed files with 805 additions and 38 deletions

View File

@@ -1027,6 +1027,86 @@ const docTemplate = `{
}
}
},
"/api/v1/area-controllers/ota/progress/{taskId}": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "根据任务ID查询指定OTA升级任务的当前进度",
"produces": [
"application/json"
],
"tags": [
"区域主控管理"
],
"summary": "查询OTA升级进度",
"parameters": [
{
"type": "string",
"description": "OTA任务ID",
"name": "taskId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/dto.OtaUpgradeProgressResponse"
}
}
}
]
}
}
}
}
},
"/api/v1/area-controllers/ota/tasks/{taskId}/stop": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "根据任务ID请求停止一个正在进行的OTA升级任务",
"produces": [
"application/json"
],
"tags": [
"区域主控管理"
],
"summary": "停止OTA升级任务",
"parameters": [
{
"type": "string",
"description": "OTA任务ID",
"name": "taskId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/controller.Response"
}
}
}
}
},
"/api/v1/area-controllers/{id}": {
"get": {
"security": [
@@ -1161,6 +1241,62 @@ const docTemplate = `{
}
}
},
"/api/v1/area-controllers/{id}/ota/start": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "为指定的区域主控上传固件并启动一个OTA升级任务",
"consumes": [
"multipart/form-data"
],
"produces": [
"application/json"
],
"tags": [
"区域主控管理"
],
"summary": "启动区域主控OTA升级",
"parameters": [
{
"type": "string",
"description": "区域主控ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "file",
"description": "固件压缩包文件",
"name": "firmware_file",
"in": "formData",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"allOf": [
{
"$ref": "#/definitions/controller.Response"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/dto.OtaUpgradeResponse"
}
}
}
]
}
}
}
}
},
"/api/v1/device-templates": {
"get": {
"security": [
@@ -3828,6 +3964,7 @@ const docTemplate = `{
},
{
"enum": [
7,
-1,
0,
1,
@@ -3837,12 +3974,12 @@ const docTemplate = `{
5,
-1,
5,
6,
7
6
],
"type": "integer",
"format": "int32",
"x-enum-varnames": [
"_numLevels",
"DebugLevel",
"InfoLevel",
"WarnLevel",
@@ -3852,8 +3989,7 @@ const docTemplate = `{
"FatalLevel",
"_minLevel",
"_maxLevel",
"InvalidLevel",
"_numLevels"
"InvalidLevel"
],
"name": "level",
"in": "query"
@@ -8252,6 +8388,44 @@ const docTemplate = `{
}
}
},
"dto.OtaUpgradeProgressResponse": {
"type": "object",
"properties": {
"current_stage": {
"description": "当前阶段",
"allOf": [
{
"$ref": "#/definitions/models.OTATaskStatus"
}
]
},
"executed_num": {
"description": "已执行步骤数",
"type": "integer"
},
"message": {
"description": "状态消息",
"type": "string"
},
"task_id": {
"description": "OTA 升级任务ID",
"type": "integer"
},
"total_num": {
"description": "总步骤数",
"type": "integer"
}
}
},
"dto.OtaUpgradeResponse": {
"type": "object",
"properties": {
"task_id": {
"description": "OTA 升级任务ID",
"type": "integer"
}
}
},
"dto.PaginationDTO": {
"type": "object",
"properties": {
@@ -10168,9 +10342,11 @@ const docTemplate = `{
"models.AIModel": {
"type": "string",
"enum": [
"None",
"Gemini"
],
"x-enum-varnames": [
"AI_MODEL_NONE",
"AI_MODEL_GEMINI"
]
},
@@ -10333,6 +10509,53 @@ const docTemplate = `{
"NotifierTypeLog"
]
},
"models.OTATaskStatus": {
"type": "string",
"enum": [
"待开始",
"进行中",
"成功",
"版本已是最新",
"预检失败",
"下载或校验失败",
"固件回滚",
"超时",
"平台内部错误"
],
"x-enum-comments": {
"OTATaskStatusAlreadyUpToDate": "设备报告版本已是最新,未执行升级",
"OTATaskStatusFailedDownload": "设备报告文件下载或校验失败 (包括清单文件和固件文件)",
"OTATaskStatusFailedPreCheck": "设备报告升级前检查失败 (如拒绝降级、准备分区失败)",
"OTATaskStatusFailedRollback": "新固件启动失败,设备自动回滚",
"OTATaskStatusInProgress": "任务已下发,设备正在处理",
"OTATaskStatusPending": "任务已创建,等待下发",
"OTATaskStatusPlatformError": "平台处理过程中发生的非设备报告错误",
"OTATaskStatusSuccess": "设备报告升级成功,新固件已运行",
"OTATaskStatusTimedOut": "平台在超时后仍未收到最终报告"
},
"x-enum-descriptions": [
"任务已创建,等待下发",
"任务已下发,设备正在处理",
"设备报告升级成功,新固件已运行",
"设备报告版本已是最新,未执行升级",
"设备报告升级前检查失败 (如拒绝降级、准备分区失败)",
"设备报告文件下载或校验失败 (包括清单文件和固件文件)",
"新固件启动失败,设备自动回滚",
"平台在超时后仍未收到最终报告",
"平台处理过程中发生的非设备报告错误"
],
"x-enum-varnames": [
"OTATaskStatusPending",
"OTATaskStatusInProgress",
"OTATaskStatusSuccess",
"OTATaskStatusAlreadyUpToDate",
"OTATaskStatusFailedPreCheck",
"OTATaskStatusFailedDownload",
"OTATaskStatusFailedRollback",
"OTATaskStatusTimedOut",
"OTATaskStatusPlatformError"
]
},
"models.Operator": {
"type": "string",
"enum": [
@@ -10700,7 +10923,8 @@ const docTemplate = `{
"告警通知",
"通知刷新",
"设备阈值检查",
"区域阈值检查"
"区域阈值检查",
"OTA升级检查任务"
],
"x-enum-comments": {
"TaskPlanAnalysis": "解析Plan的Task列表并添加到待执行队列的特殊任务",
@@ -10710,6 +10934,7 @@ const docTemplate = `{
"TaskTypeFullCollection": "新增的全量采集任务",
"TaskTypeHeartbeat": "区域主控心跳检测任务",
"TaskTypeNotificationRefresh": "通知刷新任务",
"TaskTypeOTACheck": "OTA升级超时检查任务",
"TaskTypeReleaseFeedWeight": "下料口释放指定重量任务",
"TaskTypeWaiting": "等待任务"
},
@@ -10722,7 +10947,8 @@ const docTemplate = `{
"告警通知任务",
"通知刷新任务",
"设备阈值检查任务",
"区域阈值检查任务"
"区域阈值检查任务",
"OTA升级超时检查任务"
],
"x-enum-varnames": [
"TaskPlanAnalysis",
@@ -10733,7 +10959,8 @@ const docTemplate = `{
"TaskTypeAlarmNotification",
"TaskTypeNotificationRefresh",
"TaskTypeDeviceThresholdCheck",
"TaskTypeAreaCollectorThresholdCheck"
"TaskTypeAreaCollectorThresholdCheck",
"TaskTypeOTACheck"
]
},
"models.ValueDescriptor": {
@@ -10769,6 +10996,7 @@ const docTemplate = `{
"type": "integer",
"format": "int32",
"enum": [
7,
-1,
0,
1,
@@ -10778,10 +11006,10 @@ const docTemplate = `{
5,
-1,
5,
6,
7
6
],
"x-enum-varnames": [
"_numLevels",
"DebugLevel",
"InfoLevel",
"WarnLevel",
@@ -10791,8 +11019,7 @@ const docTemplate = `{
"FatalLevel",
"_minLevel",
"_maxLevel",
"InvalidLevel",
"_numLevels"
"InvalidLevel"
]
}
},