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

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"
]
}
},

View File

@@ -1019,6 +1019,86 @@
}
}
},
"/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": [
@@ -1153,6 +1233,62 @@
}
}
},
"/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": [
@@ -3820,6 +3956,7 @@
},
{
"enum": [
7,
-1,
0,
1,
@@ -3829,12 +3966,12 @@
5,
-1,
5,
6,
7
6
],
"type": "integer",
"format": "int32",
"x-enum-varnames": [
"_numLevels",
"DebugLevel",
"InfoLevel",
"WarnLevel",
@@ -3844,8 +3981,7 @@
"FatalLevel",
"_minLevel",
"_maxLevel",
"InvalidLevel",
"_numLevels"
"InvalidLevel"
],
"name": "level",
"in": "query"
@@ -8244,6 +8380,44 @@
}
}
},
"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": {
@@ -10160,9 +10334,11 @@
"models.AIModel": {
"type": "string",
"enum": [
"None",
"Gemini"
],
"x-enum-varnames": [
"AI_MODEL_NONE",
"AI_MODEL_GEMINI"
]
},
@@ -10325,6 +10501,53 @@
"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": [
@@ -10692,7 +10915,8 @@
"告警通知",
"通知刷新",
"设备阈值检查",
"区域阈值检查"
"区域阈值检查",
"OTA升级检查任务"
],
"x-enum-comments": {
"TaskPlanAnalysis": "解析Plan的Task列表并添加到待执行队列的特殊任务",
@@ -10702,6 +10926,7 @@
"TaskTypeFullCollection": "新增的全量采集任务",
"TaskTypeHeartbeat": "区域主控心跳检测任务",
"TaskTypeNotificationRefresh": "通知刷新任务",
"TaskTypeOTACheck": "OTA升级超时检查任务",
"TaskTypeReleaseFeedWeight": "下料口释放指定重量任务",
"TaskTypeWaiting": "等待任务"
},
@@ -10714,7 +10939,8 @@
"告警通知任务",
"通知刷新任务",
"设备阈值检查任务",
"区域阈值检查任务"
"区域阈值检查任务",
"OTA升级超时检查任务"
],
"x-enum-varnames": [
"TaskPlanAnalysis",
@@ -10725,7 +10951,8 @@
"TaskTypeAlarmNotification",
"TaskTypeNotificationRefresh",
"TaskTypeDeviceThresholdCheck",
"TaskTypeAreaCollectorThresholdCheck"
"TaskTypeAreaCollectorThresholdCheck",
"TaskTypeOTACheck"
]
},
"models.ValueDescriptor": {
@@ -10761,6 +10988,7 @@
"type": "integer",
"format": "int32",
"enum": [
7,
-1,
0,
1,
@@ -10770,10 +10998,10 @@
5,
-1,
5,
6,
7
6
],
"x-enum-varnames": [
"_numLevels",
"DebugLevel",
"InfoLevel",
"WarnLevel",
@@ -10783,8 +11011,7 @@
"FatalLevel",
"_minLevel",
"_maxLevel",
"InvalidLevel",
"_numLevels"
"InvalidLevel"
]
}
},

View File

@@ -994,6 +994,31 @@ definitions:
$ref: '#/definitions/dto.NutrientRawMaterialDTO'
type: array
type: object
dto.OtaUpgradeProgressResponse:
properties:
current_stage:
allOf:
- $ref: '#/definitions/models.OTATaskStatus'
description: 当前阶段
executed_num:
description: 已执行步骤数
type: integer
message:
description: 状态消息
type: string
task_id:
description: OTA 升级任务ID
type: integer
total_num:
description: 总步骤数
type: integer
type: object
dto.OtaUpgradeResponse:
properties:
task_id:
description: OTA 升级任务ID
type: integer
type: object
dto.PaginationDTO:
properties:
page:
@@ -2288,9 +2313,11 @@ definitions:
type: object
models.AIModel:
enum:
- None
- Gemini
type: string
x-enum-varnames:
- AI_MODEL_NONE
- AI_MODEL_GEMINI
models.AlarmCode:
enum:
@@ -2420,6 +2447,48 @@ definitions:
- NotifierTypeWeChat
- NotifierTypeLark
- NotifierTypeLog
models.OTATaskStatus:
enum:
- 待开始
- 进行中
- 成功
- 版本已是最新
- 预检失败
- 下载或校验失败
- 固件回滚
- 超时
- 平台内部错误
type: string
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:
enum:
- <
@@ -2724,6 +2793,7 @@ definitions:
- 通知刷新
- 设备阈值检查
- 区域阈值检查
- OTA升级检查任务
type: string
x-enum-comments:
TaskPlanAnalysis: 解析Plan的Task列表并添加到待执行队列的特殊任务
@@ -2733,6 +2803,7 @@ definitions:
TaskTypeFullCollection: 新增的全量采集任务
TaskTypeHeartbeat: 区域主控心跳检测任务
TaskTypeNotificationRefresh: 通知刷新任务
TaskTypeOTACheck: OTA升级超时检查任务
TaskTypeReleaseFeedWeight: 下料口释放指定重量任务
TaskTypeWaiting: 等待任务
x-enum-descriptions:
@@ -2745,6 +2816,7 @@ definitions:
- 通知刷新任务
- 设备阈值检查任务
- 区域阈值检查任务
- OTA升级超时检查任务
x-enum-varnames:
- TaskPlanAnalysis
- TaskTypeWaiting
@@ -2755,6 +2827,7 @@ definitions:
- TaskTypeNotificationRefresh
- TaskTypeDeviceThresholdCheck
- TaskTypeAreaCollectorThresholdCheck
- TaskTypeOTACheck
models.ValueDescriptor:
properties:
multiplier:
@@ -2778,6 +2851,7 @@ definitions:
- PlanTypeFilterSystem
zapcore.Level:
enum:
- 7
- -1
- 0
- 1
@@ -2788,10 +2862,10 @@ definitions:
- -1
- 5
- 6
- 7
format: int32
type: integer
x-enum-varnames:
- _numLevels
- DebugLevel
- InfoLevel
- WarnLevel
@@ -2802,7 +2876,6 @@ definitions:
- _minLevel
- _maxLevel
- InvalidLevel
- _numLevels
info:
contact:
email: divano@example.com
@@ -3542,6 +3615,86 @@ paths:
summary: 更新区域主控信息
tags:
- 区域主控管理
/api/v1/area-controllers/{id}/ota/start:
post:
consumes:
- multipart/form-data
description: 为指定的区域主控上传固件并启动一个OTA升级任务
parameters:
- description: 区域主控ID
in: path
name: id
required: true
type: string
- description: 固件压缩包文件
in: formData
name: firmware_file
required: true
type: file
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/dto.OtaUpgradeResponse'
type: object
security:
- BearerAuth: []
summary: 启动区域主控OTA升级
tags:
- 区域主控管理
/api/v1/area-controllers/ota/progress/{taskId}:
get:
description: 根据任务ID查询指定OTA升级任务的当前进度
parameters:
- description: OTA任务ID
in: path
name: taskId
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
allOf:
- $ref: '#/definitions/controller.Response'
- properties:
data:
$ref: '#/definitions/dto.OtaUpgradeProgressResponse'
type: object
security:
- BearerAuth: []
summary: 查询OTA升级进度
tags:
- 区域主控管理
/api/v1/area-controllers/ota/tasks/{taskId}/stop:
post:
description: 根据任务ID请求停止一个正在进行的OTA升级任务
parameters:
- description: OTA任务ID
in: path
name: taskId
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/controller.Response'
security:
- BearerAuth: []
summary: 停止OTA升级任务
tags:
- 区域主控管理
/api/v1/device-templates:
get:
description: 获取系统中所有设备模板的列表
@@ -5101,6 +5254,7 @@ paths:
name: end_time
type: string
- enum:
- 7
- -1
- 0
- 1
@@ -5111,12 +5265,12 @@ paths:
- -1
- 5
- 6
- 7
format: int32
in: query
name: level
type: integer
x-enum-varnames:
- _numLevels
- DebugLevel
- InfoLevel
- WarnLevel
@@ -5127,7 +5281,6 @@ paths:
- _minLevel
- _maxLevel
- InvalidLevel
- _numLevels
- enum:
- 邮件
- 企业微信