diff --git a/docs/docs.go b/docs/docs.go deleted file mode 100644 index fb7fc98..0000000 --- a/docs/docs.go +++ /dev/null @@ -1,1871 +0,0 @@ -// Package docs Code generated by swaggo/swag. DO NOT EDIT -package docs - -import "github.com/swaggo/swag" - -const docTemplate = `{ - "schemes": {{ marshal .Schemes }}, - "swagger": "2.0", - "info": { - "description": "{{escape .Description}}", - "title": "{{.Title}}", - "contact": {}, - "version": "{{.Version}}" - }, - "host": "{{.Host}}", - "basePath": "{{.BasePath}}", - "paths": { - "/api/v1/area-controllers": { - "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.AreaControllerResponse" - } - } - } - } - ] - } - } - } - }, - "post": { - "description": "根据提供的信息创建一个新区域主控", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "区域主控管理" - ], - "summary": "创建新区域主控", - "parameters": [ - { - "description": "区域主控信息", - "name": "areaController", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/device.CreateAreaControllerRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/device.AreaControllerResponse" - } - } - } - ] - } - } - } - } - }, - "/api/v1/area-controllers/{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.AreaControllerResponse" - } - } - } - ] - } - } - } - }, - "put": { - "description": "根据ID更新一个已存在的区域主控信息", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "区域主控管理" - ], - "summary": "更新区域主控信息", - "parameters": [ - { - "type": "string", - "description": "区域主控ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "要更新的区域主控信息", - "name": "areaController", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/device.UpdateAreaControllerRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/device.AreaControllerResponse" - } - } - } - ] - } - } - } - }, - "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/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": "获取系统中所有设备的列表", - "produces": [ - "application/json" - ], - "tags": [ - "设备管理" - ], - "summary": "获取设备列表", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse" - } - } - } - } - ] - } - } - } - }, - "post": { - "description": "根据提供的信息创建一个新设备", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "设备管理" - ], - "summary": "创建新设备", - "parameters": [ - { - "description": "设备信息", - "name": "device", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/device.CreateDeviceRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse" - } - } - } - ] - } - } - } - } - }, - "/api/v1/devices/{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/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse" - } - } - } - ] - } - } - } - }, - "put": { - "description": "根据设备ID更新一个已存在的设备信息", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "设备管理" - ], - "summary": "更新设备信息", - "parameters": [ - { - "type": "string", - "description": "设备ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "要更新的设备信息", - "name": "device", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/device.UpdateDeviceRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse" - } - } - } - ] - } - } - } - }, - "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/plans": { - "get": { - "description": "获取所有计划的列表", - "produces": [ - "application/json" - ], - "tags": [ - "计划管理" - ], - "summary": "获取计划列表", - "responses": { - "200": { - "description": "业务码为200代表成功获取列表", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/plan.ListPlansResponse" - } - } - } - ] - } - } - } - }, - "post": { - "description": "创建一个新的计划,包括其基本信息和所有关联的子计划/任务。", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "计划管理" - ], - "summary": "创建计划", - "parameters": [ - { - "description": "计划信息", - "name": "plan", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/plan.CreatePlanRequest" - } - } - ], - "responses": { - "200": { - "description": "业务码为201代表创建成功", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/plan.PlanResponse" - } - } - } - ] - } - } - } - } - }, - "/api/v1/plans/{id}": { - "get": { - "description": "根据计划ID获取单个计划的详细信息。", - "produces": [ - "application/json" - ], - "tags": [ - "计划管理" - ], - "summary": "获取计划详情", - "parameters": [ - { - "type": "integer", - "description": "计划ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "业务码为200代表成功获取", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/plan.PlanResponse" - } - } - } - ] - } - } - } - }, - "put": { - "description": "根据计划ID更新计划的详细信息。", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "计划管理" - ], - "summary": "更新计划", - "parameters": [ - { - "type": "integer", - "description": "计划ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "更新后的计划信息", - "name": "plan", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/plan.UpdatePlanRequest" - } - } - ], - "responses": { - "200": { - "description": "业务码为200代表更新成功", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/plan.PlanResponse" - } - } - } - ] - } - } - } - }, - "delete": { - "description": "根据计划ID删除计划。(软删除)", - "produces": [ - "application/json" - ], - "tags": [ - "计划管理" - ], - "summary": "删除计划", - "parameters": [ - { - "type": "integer", - "description": "计划ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "业务码为200代表删除成功", - "schema": { - "$ref": "#/definitions/controller.Response" - } - } - } - } - }, - "/api/v1/plans/{id}/start": { - "post": { - "description": "根据计划ID启动一个计划的执行。", - "produces": [ - "application/json" - ], - "tags": [ - "计划管理" - ], - "summary": "启动计划", - "parameters": [ - { - "type": "integer", - "description": "计划ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "业务码为200代表成功启动计划", - "schema": { - "$ref": "#/definitions/controller.Response" - } - } - } - } - }, - "/api/v1/plans/{id}/stop": { - "post": { - "description": "根据计划ID停止一个正在执行的计划。", - "produces": [ - "application/json" - ], - "tags": [ - "计划管理" - ], - "summary": "停止计划", - "parameters": [ - { - "type": "integer", - "description": "计划ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "业务码为200代表成功停止计划", - "schema": { - "$ref": "#/definitions/controller.Response" - } - } - } - } - }, - "/api/v1/users": { - "post": { - "description": "根据用户名和密码创建一个新的系统用户。", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "用户管理" - ], - "summary": "创建新用户", - "parameters": [ - { - "description": "用户信息", - "name": "user", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/user.CreateUserRequest" - } - } - ], - "responses": { - "200": { - "description": "业务码为201代表创建成功", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/user.CreateUserResponse" - } - } - } - ] - } - } - } - } - }, - "/api/v1/users/login": { - "post": { - "description": "用户可以使用用户名、邮箱、手机号、微信号或飞书账号进行登录,成功后返回 JWT 令牌。", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "用户管理" - ], - "summary": "用户登录", - "parameters": [ - { - "description": "登录凭证", - "name": "credentials", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/user.LoginRequest" - } - } - ], - "responses": { - "200": { - "description": "业务码为200代表登录成功", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/user.LoginResponse" - } - } - } - ] - } - } - } - } - }, - "/api/v1/users/{id}/history": { - "get": { - "description": "根据用户ID,分页获取该用户的操作审计日志。", - "produces": [ - "application/json" - ], - "tags": [ - "用户管理" - ], - "summary": "获取指定用户的操作历史", - "parameters": [ - { - "type": "integer", - "description": "用户ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "default": 1, - "description": "页码", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "default": 10, - "description": "每页大小", - "name": "page_size", - "in": "query" - }, - { - "type": "string", - "description": "按操作类型过滤", - "name": "action_type", - "in": "query" - } - ], - "responses": { - "200": { - "description": "业务码为200代表成功获取", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/user.ListHistoryResponse" - } - } - } - ] - } - } - } - } - } - }, - "definitions": { - "controller.Response": { - "type": "object", - "properties": { - "code": { - "description": "业务状态码", - "allOf": [ - { - "$ref": "#/definitions/controller.ResponseCode" - } - ] - }, - "data": { - "description": "业务数据" - }, - "message": { - "description": "提示信息", - "type": "string" - } - } - }, - "controller.ResponseCode": { - "type": "integer", - "enum": [ - 2000, - 2001, - 4000, - 4001, - 4004, - 4009, - 5000, - 5003 - ], - "x-enum-comments": { - "CodeBadRequest": "请求参数错误", - "CodeConflict": "资源冲突", - "CodeCreated": "创建成功", - "CodeInternalError": "服务器内部错误", - "CodeNotFound": "资源未找到", - "CodeServiceUnavailable": "服务不可用", - "CodeSuccess": "操作成功", - "CodeUnauthorized": "未授权" - }, - "x-enum-descriptions": [ - "操作成功", - "创建成功", - "请求参数错误", - "未授权", - "资源未找到", - "资源冲突", - "服务器内部错误", - "服务不可用" - ], - "x-enum-varnames": [ - "CodeSuccess", - "CodeCreated", - "CodeBadRequest", - "CodeUnauthorized", - "CodeNotFound", - "CodeConflict", - "CodeInternalError", - "CodeServiceUnavailable" - ] - }, - "device.AreaControllerResponse": { - "type": "object", - "properties": { - "created_at": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "location": { - "type": "string" - }, - "name": { - "type": "string" - }, - "network_id": { - "type": "string" - }, - "properties": { - "type": "object", - "additionalProperties": true - }, - "status": { - "type": "string" - }, - "updated_at": { - "type": "string" - } - } - }, - "device.CreateAreaControllerRequest": { - "type": "object", - "required": [ - "name", - "network_id" - ], - "properties": { - "location": { - "type": "string" - }, - "name": { - "type": "string" - }, - "network_id": { - "type": "string" - }, - "properties": { - "type": "object", - "additionalProperties": true - } - } - }, - "device.CreateDeviceRequest": { - "type": "object", - "required": [ - "area_controller_id", - "device_template_id", - "name" - ], - "properties": { - "area_controller_id": { - "type": "integer" - }, - "device_template_id": { - "type": "integer" - }, - "location": { - "type": "string" - }, - "name": { - "type": "string" - }, - "properties": { - "type": "object", - "additionalProperties": true - } - } - }, - "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": [ - "name", - "network_id" - ], - "properties": { - "location": { - "type": "string" - }, - "name": { - "type": "string" - }, - "network_id": { - "type": "string" - }, - "properties": { - "type": "object", - "additionalProperties": true - } - } - }, - "device.UpdateDeviceRequest": { - "type": "object", - "required": [ - "area_controller_id", - "device_template_id", - "name" - ], - "properties": { - "area_controller_id": { - "type": "integer" - }, - "device_template_id": { - "type": "integer" - }, - "location": { - "type": "string" - }, - "name": { - "type": "string" - }, - "properties": { - "type": "object", - "additionalProperties": true - } - } - }, - "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": { - "area_controller_id": { - "type": "integer" - }, - "area_controller_name": { - "type": "string" - }, - "created_at": { - "type": "string" - }, - "device_template_id": { - "type": "integer" - }, - "device_template_name": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "location": { - "type": "string" - }, - "name": { - "type": "string" - }, - "properties": { - "type": "object", - "additionalProperties": true - }, - "updated_at": { - "type": "string" - } - } - }, - "models.DeviceCategory": { - "type": "string", - "enum": [ - "执行器", - "传感器" - ], - "x-enum-varnames": [ - "CategoryActuator", - "CategorySensor" - ] - }, - "models.PlanContentType": { - "type": "string", - "enum": [ - "子计划", - "任务" - ], - "x-enum-comments": { - "PlanContentTypeSubPlans": "计划包含子计划", - "PlanContentTypeTasks": "计划包含任务" - }, - "x-enum-descriptions": [ - "计划包含子计划", - "计划包含任务" - ], - "x-enum-varnames": [ - "PlanContentTypeSubPlans", - "PlanContentTypeTasks" - ] - }, - "models.PlanExecutionType": { - "type": "string", - "enum": [ - "自动", - "手动" - ], - "x-enum-comments": { - "PlanExecutionTypeAutomatic": "自动执行 (包含定时和循环)", - "PlanExecutionTypeManual": "手动执行" - }, - "x-enum-descriptions": [ - "自动执行 (包含定时和循环)", - "手动执行" - ], - "x-enum-varnames": [ - "PlanExecutionTypeAutomatic", - "PlanExecutionTypeManual" - ] - }, - "models.PlanStatus": { - "type": "string", - "enum": [ - "已禁用", - "已启用", - "执行完毕", - "执行失败" - ], - "x-enum-comments": { - "PlanStatusDisabled": "禁用计划", - "PlanStatusEnabled": "启用计划", - "PlanStatusFailed": "执行失败", - "PlanStatusStopped": "执行完毕" - }, - "x-enum-descriptions": [ - "禁用计划", - "启用计划", - "执行完毕", - "执行失败" - ], - "x-enum-varnames": [ - "PlanStatusDisabled", - "PlanStatusEnabled", - "PlanStatusStopped", - "PlanStatusFailed" - ] - }, - "models.SensorType": { - "type": "string", - "enum": [ - "信号强度", - "电池电量", - "温度", - "湿度", - "重量" - ], - "x-enum-comments": { - "SensorTypeBatteryLevel": "电池电量", - "SensorTypeHumidity": "湿度", - "SensorTypeSignalMetrics": "信号强度", - "SensorTypeTemperature": "温度", - "SensorTypeWeight": "重量" - }, - "x-enum-descriptions": [ - "信号强度", - "电池电量", - "温度", - "湿度", - "重量" - ], - "x-enum-varnames": [ - "SensorTypeSignalMetrics", - "SensorTypeBatteryLevel", - "SensorTypeTemperature", - "SensorTypeHumidity", - "SensorTypeWeight" - ] - }, - "models.TaskType": { - "type": "string", - "enum": [ - "计划分析", - "等待", - "下料" - ], - "x-enum-comments": { - "TaskPlanAnalysis": "解析Plan的Task列表并添加到待执行队列的特殊任务", - "TaskTypeReleaseFeedWeight": "下料口释放指定重量任务", - "TaskTypeWaiting": "等待任务" - }, - "x-enum-descriptions": [ - "解析Plan的Task列表并添加到待执行队列的特殊任务", - "等待任务", - "下料口释放指定重量任务" - ], - "x-enum-varnames": [ - "TaskPlanAnalysis", - "TaskTypeWaiting", - "TaskTypeReleaseFeedWeight" - ] - }, - "models.ValueDescriptor": { - "type": "object", - "properties": { - "multiplier": { - "description": "乘数,用于原始数据转换", - "type": "number" - }, - "offset": { - "description": "偏移量,用于原始数据转换", - "type": "number" - }, - "type": { - "$ref": "#/definitions/models.SensorType" - } - } - }, - "plan.CreatePlanRequest": { - "type": "object", - "required": [ - "execution_type", - "name" - ], - "properties": { - "cron_expression": { - "type": "string", - "example": "0 0 6 * * *" - }, - "description": { - "type": "string", - "example": "根据温度自动调节风扇和加热器" - }, - "execute_num": { - "type": "integer", - "example": 10 - }, - "execution_type": { - "allOf": [ - { - "$ref": "#/definitions/models.PlanExecutionType" - } - ], - "example": "自动" - }, - "name": { - "type": "string", - "example": "猪舍温度控制计划" - }, - "sub_plan_ids": { - "type": "array", - "items": { - "type": "integer" - } - }, - "tasks": { - "type": "array", - "items": { - "$ref": "#/definitions/plan.TaskRequest" - } - } - } - }, - "plan.ListPlansResponse": { - "type": "object", - "properties": { - "plans": { - "type": "array", - "items": { - "$ref": "#/definitions/plan.PlanResponse" - } - }, - "total": { - "type": "integer", - "example": 100 - } - } - }, - "plan.PlanResponse": { - "type": "object", - "properties": { - "content_type": { - "allOf": [ - { - "$ref": "#/definitions/models.PlanContentType" - } - ], - "example": "任务" - }, - "cron_expression": { - "type": "string", - "example": "0 0 6 * * *" - }, - "description": { - "type": "string", - "example": "根据温度自动调节风扇和加热器" - }, - "execute_count": { - "type": "integer", - "example": 0 - }, - "execute_num": { - "type": "integer", - "example": 10 - }, - "execution_type": { - "allOf": [ - { - "$ref": "#/definitions/models.PlanExecutionType" - } - ], - "example": "自动" - }, - "id": { - "type": "integer", - "example": 1 - }, - "name": { - "type": "string", - "example": "猪舍温度控制计划" - }, - "status": { - "allOf": [ - { - "$ref": "#/definitions/models.PlanStatus" - } - ], - "example": "已启用" - }, - "sub_plans": { - "type": "array", - "items": { - "$ref": "#/definitions/plan.SubPlanResponse" - } - }, - "tasks": { - "type": "array", - "items": { - "$ref": "#/definitions/plan.TaskResponse" - } - } - } - }, - "plan.SubPlanResponse": { - "type": "object", - "properties": { - "child_plan": { - "$ref": "#/definitions/plan.PlanResponse" - }, - "child_plan_id": { - "type": "integer", - "example": 2 - }, - "execution_order": { - "type": "integer", - "example": 1 - }, - "id": { - "type": "integer", - "example": 1 - }, - "parent_plan_id": { - "type": "integer", - "example": 1 - } - } - }, - "plan.TaskRequest": { - "type": "object", - "properties": { - "description": { - "type": "string", - "example": "打开1号风扇" - }, - "execution_order": { - "type": "integer", - "example": 1 - }, - "name": { - "type": "string", - "example": "打开风扇" - }, - "parameters": { - "type": "object", - "additionalProperties": true - }, - "type": { - "allOf": [ - { - "$ref": "#/definitions/models.TaskType" - } - ], - "example": "等待" - } - } - }, - "plan.TaskResponse": { - "type": "object", - "properties": { - "description": { - "type": "string", - "example": "打开1号风扇" - }, - "execution_order": { - "type": "integer", - "example": 1 - }, - "id": { - "type": "integer", - "example": 1 - }, - "name": { - "type": "string", - "example": "打开风扇" - }, - "parameters": { - "type": "object", - "additionalProperties": true - }, - "plan_id": { - "type": "integer", - "example": 1 - }, - "type": { - "allOf": [ - { - "$ref": "#/definitions/models.TaskType" - } - ], - "example": "等待" - } - } - }, - "plan.UpdatePlanRequest": { - "type": "object", - "properties": { - "cron_expression": { - "type": "string", - "example": "0 0 6 * * *" - }, - "description": { - "type": "string", - "example": "更新后的描述" - }, - "execute_num": { - "type": "integer", - "example": 10 - }, - "execution_type": { - "allOf": [ - { - "$ref": "#/definitions/models.PlanExecutionType" - } - ], - "example": "自动" - }, - "name": { - "type": "string", - "example": "猪舍温度控制计划V2" - }, - "sub_plan_ids": { - "type": "array", - "items": { - "type": "integer" - } - }, - "tasks": { - "type": "array", - "items": { - "$ref": "#/definitions/plan.TaskRequest" - } - } - } - }, - "user.CreateUserRequest": { - "type": "object", - "required": [ - "password", - "username" - ], - "properties": { - "password": { - "type": "string", - "example": "password123" - }, - "username": { - "type": "string", - "example": "newuser" - } - } - }, - "user.CreateUserResponse": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "example": 1 - }, - "username": { - "type": "string", - "example": "newuser" - } - } - }, - "user.HistoryResponse": { - "type": "object", - "properties": { - "action_type": { - "type": "string", - "example": "更新设备" - }, - "description": { - "type": "string", - "example": "设备更新成功" - }, - "target_resource": {}, - "time": { - "type": "string" - }, - "user_id": { - "type": "integer", - "example": 101 - }, - "username": { - "type": "string", - "example": "testuser" - } - } - }, - "user.ListHistoryResponse": { - "type": "object", - "properties": { - "history": { - "type": "array", - "items": { - "$ref": "#/definitions/user.HistoryResponse" - } - }, - "total": { - "type": "integer", - "example": 100 - } - } - }, - "user.LoginRequest": { - "type": "object", - "required": [ - "identifier", - "password" - ], - "properties": { - "identifier": { - "description": "Identifier 可以是用户名、邮箱、手机号、微信号或飞书账号", - "type": "string", - "example": "testuser" - }, - "password": { - "type": "string", - "example": "password123" - } - } - }, - "user.LoginResponse": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "example": 1 - }, - "token": { - "type": "string", - "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." - }, - "username": { - "type": "string", - "example": "testuser" - } - } - } - } -}` - -// SwaggerInfo holds exported Swagger Info so clients can modify it -var SwaggerInfo = &swag.Spec{ - Version: "", - Host: "", - BasePath: "", - Schemes: []string{}, - Title: "", - Description: "", - InfoInstanceName: "swagger", - SwaggerTemplate: docTemplate, - LeftDelim: "{{", - RightDelim: "}}", -} - -func init() { - swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) -} diff --git a/docs/swagger.json b/docs/swagger.json deleted file mode 100644 index 60e6dec..0000000 --- a/docs/swagger.json +++ /dev/null @@ -1,1842 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "contact": {} - }, - "paths": { - "/api/v1/area-controllers": { - "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.AreaControllerResponse" - } - } - } - } - ] - } - } - } - }, - "post": { - "description": "根据提供的信息创建一个新区域主控", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "区域主控管理" - ], - "summary": "创建新区域主控", - "parameters": [ - { - "description": "区域主控信息", - "name": "areaController", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/device.CreateAreaControllerRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/device.AreaControllerResponse" - } - } - } - ] - } - } - } - } - }, - "/api/v1/area-controllers/{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.AreaControllerResponse" - } - } - } - ] - } - } - } - }, - "put": { - "description": "根据ID更新一个已存在的区域主控信息", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "区域主控管理" - ], - "summary": "更新区域主控信息", - "parameters": [ - { - "type": "string", - "description": "区域主控ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "要更新的区域主控信息", - "name": "areaController", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/device.UpdateAreaControllerRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/device.AreaControllerResponse" - } - } - } - ] - } - } - } - }, - "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/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": "获取系统中所有设备的列表", - "produces": [ - "application/json" - ], - "tags": [ - "设备管理" - ], - "summary": "获取设备列表", - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse" - } - } - } - } - ] - } - } - } - }, - "post": { - "description": "根据提供的信息创建一个新设备", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "设备管理" - ], - "summary": "创建新设备", - "parameters": [ - { - "description": "设备信息", - "name": "device", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/device.CreateDeviceRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse" - } - } - } - ] - } - } - } - } - }, - "/api/v1/devices/{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/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse" - } - } - } - ] - } - } - } - }, - "put": { - "description": "根据设备ID更新一个已存在的设备信息", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "设备管理" - ], - "summary": "更新设备信息", - "parameters": [ - { - "type": "string", - "description": "设备ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "要更新的设备信息", - "name": "device", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/device.UpdateDeviceRequest" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse" - } - } - } - ] - } - } - } - }, - "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/plans": { - "get": { - "description": "获取所有计划的列表", - "produces": [ - "application/json" - ], - "tags": [ - "计划管理" - ], - "summary": "获取计划列表", - "responses": { - "200": { - "description": "业务码为200代表成功获取列表", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/plan.ListPlansResponse" - } - } - } - ] - } - } - } - }, - "post": { - "description": "创建一个新的计划,包括其基本信息和所有关联的子计划/任务。", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "计划管理" - ], - "summary": "创建计划", - "parameters": [ - { - "description": "计划信息", - "name": "plan", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/plan.CreatePlanRequest" - } - } - ], - "responses": { - "200": { - "description": "业务码为201代表创建成功", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/plan.PlanResponse" - } - } - } - ] - } - } - } - } - }, - "/api/v1/plans/{id}": { - "get": { - "description": "根据计划ID获取单个计划的详细信息。", - "produces": [ - "application/json" - ], - "tags": [ - "计划管理" - ], - "summary": "获取计划详情", - "parameters": [ - { - "type": "integer", - "description": "计划ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "业务码为200代表成功获取", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/plan.PlanResponse" - } - } - } - ] - } - } - } - }, - "put": { - "description": "根据计划ID更新计划的详细信息。", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "计划管理" - ], - "summary": "更新计划", - "parameters": [ - { - "type": "integer", - "description": "计划ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "更新后的计划信息", - "name": "plan", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/plan.UpdatePlanRequest" - } - } - ], - "responses": { - "200": { - "description": "业务码为200代表更新成功", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/plan.PlanResponse" - } - } - } - ] - } - } - } - }, - "delete": { - "description": "根据计划ID删除计划。(软删除)", - "produces": [ - "application/json" - ], - "tags": [ - "计划管理" - ], - "summary": "删除计划", - "parameters": [ - { - "type": "integer", - "description": "计划ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "业务码为200代表删除成功", - "schema": { - "$ref": "#/definitions/controller.Response" - } - } - } - } - }, - "/api/v1/plans/{id}/start": { - "post": { - "description": "根据计划ID启动一个计划的执行。", - "produces": [ - "application/json" - ], - "tags": [ - "计划管理" - ], - "summary": "启动计划", - "parameters": [ - { - "type": "integer", - "description": "计划ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "业务码为200代表成功启动计划", - "schema": { - "$ref": "#/definitions/controller.Response" - } - } - } - } - }, - "/api/v1/plans/{id}/stop": { - "post": { - "description": "根据计划ID停止一个正在执行的计划。", - "produces": [ - "application/json" - ], - "tags": [ - "计划管理" - ], - "summary": "停止计划", - "parameters": [ - { - "type": "integer", - "description": "计划ID", - "name": "id", - "in": "path", - "required": true - } - ], - "responses": { - "200": { - "description": "业务码为200代表成功停止计划", - "schema": { - "$ref": "#/definitions/controller.Response" - } - } - } - } - }, - "/api/v1/users": { - "post": { - "description": "根据用户名和密码创建一个新的系统用户。", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "用户管理" - ], - "summary": "创建新用户", - "parameters": [ - { - "description": "用户信息", - "name": "user", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/user.CreateUserRequest" - } - } - ], - "responses": { - "200": { - "description": "业务码为201代表创建成功", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/user.CreateUserResponse" - } - } - } - ] - } - } - } - } - }, - "/api/v1/users/login": { - "post": { - "description": "用户可以使用用户名、邮箱、手机号、微信号或飞书账号进行登录,成功后返回 JWT 令牌。", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "用户管理" - ], - "summary": "用户登录", - "parameters": [ - { - "description": "登录凭证", - "name": "credentials", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/user.LoginRequest" - } - } - ], - "responses": { - "200": { - "description": "业务码为200代表登录成功", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/user.LoginResponse" - } - } - } - ] - } - } - } - } - }, - "/api/v1/users/{id}/history": { - "get": { - "description": "根据用户ID,分页获取该用户的操作审计日志。", - "produces": [ - "application/json" - ], - "tags": [ - "用户管理" - ], - "summary": "获取指定用户的操作历史", - "parameters": [ - { - "type": "integer", - "description": "用户ID", - "name": "id", - "in": "path", - "required": true - }, - { - "type": "integer", - "default": 1, - "description": "页码", - "name": "page", - "in": "query" - }, - { - "type": "integer", - "default": 10, - "description": "每页大小", - "name": "page_size", - "in": "query" - }, - { - "type": "string", - "description": "按操作类型过滤", - "name": "action_type", - "in": "query" - } - ], - "responses": { - "200": { - "description": "业务码为200代表成功获取", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/controller.Response" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/definitions/user.ListHistoryResponse" - } - } - } - ] - } - } - } - } - } - }, - "definitions": { - "controller.Response": { - "type": "object", - "properties": { - "code": { - "description": "业务状态码", - "allOf": [ - { - "$ref": "#/definitions/controller.ResponseCode" - } - ] - }, - "data": { - "description": "业务数据" - }, - "message": { - "description": "提示信息", - "type": "string" - } - } - }, - "controller.ResponseCode": { - "type": "integer", - "enum": [ - 2000, - 2001, - 4000, - 4001, - 4004, - 4009, - 5000, - 5003 - ], - "x-enum-comments": { - "CodeBadRequest": "请求参数错误", - "CodeConflict": "资源冲突", - "CodeCreated": "创建成功", - "CodeInternalError": "服务器内部错误", - "CodeNotFound": "资源未找到", - "CodeServiceUnavailable": "服务不可用", - "CodeSuccess": "操作成功", - "CodeUnauthorized": "未授权" - }, - "x-enum-descriptions": [ - "操作成功", - "创建成功", - "请求参数错误", - "未授权", - "资源未找到", - "资源冲突", - "服务器内部错误", - "服务不可用" - ], - "x-enum-varnames": [ - "CodeSuccess", - "CodeCreated", - "CodeBadRequest", - "CodeUnauthorized", - "CodeNotFound", - "CodeConflict", - "CodeInternalError", - "CodeServiceUnavailable" - ] - }, - "device.AreaControllerResponse": { - "type": "object", - "properties": { - "created_at": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "location": { - "type": "string" - }, - "name": { - "type": "string" - }, - "network_id": { - "type": "string" - }, - "properties": { - "type": "object", - "additionalProperties": true - }, - "status": { - "type": "string" - }, - "updated_at": { - "type": "string" - } - } - }, - "device.CreateAreaControllerRequest": { - "type": "object", - "required": [ - "name", - "network_id" - ], - "properties": { - "location": { - "type": "string" - }, - "name": { - "type": "string" - }, - "network_id": { - "type": "string" - }, - "properties": { - "type": "object", - "additionalProperties": true - } - } - }, - "device.CreateDeviceRequest": { - "type": "object", - "required": [ - "area_controller_id", - "device_template_id", - "name" - ], - "properties": { - "area_controller_id": { - "type": "integer" - }, - "device_template_id": { - "type": "integer" - }, - "location": { - "type": "string" - }, - "name": { - "type": "string" - }, - "properties": { - "type": "object", - "additionalProperties": true - } - } - }, - "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": [ - "name", - "network_id" - ], - "properties": { - "location": { - "type": "string" - }, - "name": { - "type": "string" - }, - "network_id": { - "type": "string" - }, - "properties": { - "type": "object", - "additionalProperties": true - } - } - }, - "device.UpdateDeviceRequest": { - "type": "object", - "required": [ - "area_controller_id", - "device_template_id", - "name" - ], - "properties": { - "area_controller_id": { - "type": "integer" - }, - "device_template_id": { - "type": "integer" - }, - "location": { - "type": "string" - }, - "name": { - "type": "string" - }, - "properties": { - "type": "object", - "additionalProperties": true - } - } - }, - "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": { - "area_controller_id": { - "type": "integer" - }, - "area_controller_name": { - "type": "string" - }, - "created_at": { - "type": "string" - }, - "device_template_id": { - "type": "integer" - }, - "device_template_name": { - "type": "string" - }, - "id": { - "type": "integer" - }, - "location": { - "type": "string" - }, - "name": { - "type": "string" - }, - "properties": { - "type": "object", - "additionalProperties": true - }, - "updated_at": { - "type": "string" - } - } - }, - "models.DeviceCategory": { - "type": "string", - "enum": [ - "执行器", - "传感器" - ], - "x-enum-varnames": [ - "CategoryActuator", - "CategorySensor" - ] - }, - "models.PlanContentType": { - "type": "string", - "enum": [ - "子计划", - "任务" - ], - "x-enum-comments": { - "PlanContentTypeSubPlans": "计划包含子计划", - "PlanContentTypeTasks": "计划包含任务" - }, - "x-enum-descriptions": [ - "计划包含子计划", - "计划包含任务" - ], - "x-enum-varnames": [ - "PlanContentTypeSubPlans", - "PlanContentTypeTasks" - ] - }, - "models.PlanExecutionType": { - "type": "string", - "enum": [ - "自动", - "手动" - ], - "x-enum-comments": { - "PlanExecutionTypeAutomatic": "自动执行 (包含定时和循环)", - "PlanExecutionTypeManual": "手动执行" - }, - "x-enum-descriptions": [ - "自动执行 (包含定时和循环)", - "手动执行" - ], - "x-enum-varnames": [ - "PlanExecutionTypeAutomatic", - "PlanExecutionTypeManual" - ] - }, - "models.PlanStatus": { - "type": "string", - "enum": [ - "已禁用", - "已启用", - "执行完毕", - "执行失败" - ], - "x-enum-comments": { - "PlanStatusDisabled": "禁用计划", - "PlanStatusEnabled": "启用计划", - "PlanStatusFailed": "执行失败", - "PlanStatusStopped": "执行完毕" - }, - "x-enum-descriptions": [ - "禁用计划", - "启用计划", - "执行完毕", - "执行失败" - ], - "x-enum-varnames": [ - "PlanStatusDisabled", - "PlanStatusEnabled", - "PlanStatusStopped", - "PlanStatusFailed" - ] - }, - "models.SensorType": { - "type": "string", - "enum": [ - "信号强度", - "电池电量", - "温度", - "湿度", - "重量" - ], - "x-enum-comments": { - "SensorTypeBatteryLevel": "电池电量", - "SensorTypeHumidity": "湿度", - "SensorTypeSignalMetrics": "信号强度", - "SensorTypeTemperature": "温度", - "SensorTypeWeight": "重量" - }, - "x-enum-descriptions": [ - "信号强度", - "电池电量", - "温度", - "湿度", - "重量" - ], - "x-enum-varnames": [ - "SensorTypeSignalMetrics", - "SensorTypeBatteryLevel", - "SensorTypeTemperature", - "SensorTypeHumidity", - "SensorTypeWeight" - ] - }, - "models.TaskType": { - "type": "string", - "enum": [ - "计划分析", - "等待", - "下料" - ], - "x-enum-comments": { - "TaskPlanAnalysis": "解析Plan的Task列表并添加到待执行队列的特殊任务", - "TaskTypeReleaseFeedWeight": "下料口释放指定重量任务", - "TaskTypeWaiting": "等待任务" - }, - "x-enum-descriptions": [ - "解析Plan的Task列表并添加到待执行队列的特殊任务", - "等待任务", - "下料口释放指定重量任务" - ], - "x-enum-varnames": [ - "TaskPlanAnalysis", - "TaskTypeWaiting", - "TaskTypeReleaseFeedWeight" - ] - }, - "models.ValueDescriptor": { - "type": "object", - "properties": { - "multiplier": { - "description": "乘数,用于原始数据转换", - "type": "number" - }, - "offset": { - "description": "偏移量,用于原始数据转换", - "type": "number" - }, - "type": { - "$ref": "#/definitions/models.SensorType" - } - } - }, - "plan.CreatePlanRequest": { - "type": "object", - "required": [ - "execution_type", - "name" - ], - "properties": { - "cron_expression": { - "type": "string", - "example": "0 0 6 * * *" - }, - "description": { - "type": "string", - "example": "根据温度自动调节风扇和加热器" - }, - "execute_num": { - "type": "integer", - "example": 10 - }, - "execution_type": { - "allOf": [ - { - "$ref": "#/definitions/models.PlanExecutionType" - } - ], - "example": "自动" - }, - "name": { - "type": "string", - "example": "猪舍温度控制计划" - }, - "sub_plan_ids": { - "type": "array", - "items": { - "type": "integer" - } - }, - "tasks": { - "type": "array", - "items": { - "$ref": "#/definitions/plan.TaskRequest" - } - } - } - }, - "plan.ListPlansResponse": { - "type": "object", - "properties": { - "plans": { - "type": "array", - "items": { - "$ref": "#/definitions/plan.PlanResponse" - } - }, - "total": { - "type": "integer", - "example": 100 - } - } - }, - "plan.PlanResponse": { - "type": "object", - "properties": { - "content_type": { - "allOf": [ - { - "$ref": "#/definitions/models.PlanContentType" - } - ], - "example": "任务" - }, - "cron_expression": { - "type": "string", - "example": "0 0 6 * * *" - }, - "description": { - "type": "string", - "example": "根据温度自动调节风扇和加热器" - }, - "execute_count": { - "type": "integer", - "example": 0 - }, - "execute_num": { - "type": "integer", - "example": 10 - }, - "execution_type": { - "allOf": [ - { - "$ref": "#/definitions/models.PlanExecutionType" - } - ], - "example": "自动" - }, - "id": { - "type": "integer", - "example": 1 - }, - "name": { - "type": "string", - "example": "猪舍温度控制计划" - }, - "status": { - "allOf": [ - { - "$ref": "#/definitions/models.PlanStatus" - } - ], - "example": "已启用" - }, - "sub_plans": { - "type": "array", - "items": { - "$ref": "#/definitions/plan.SubPlanResponse" - } - }, - "tasks": { - "type": "array", - "items": { - "$ref": "#/definitions/plan.TaskResponse" - } - } - } - }, - "plan.SubPlanResponse": { - "type": "object", - "properties": { - "child_plan": { - "$ref": "#/definitions/plan.PlanResponse" - }, - "child_plan_id": { - "type": "integer", - "example": 2 - }, - "execution_order": { - "type": "integer", - "example": 1 - }, - "id": { - "type": "integer", - "example": 1 - }, - "parent_plan_id": { - "type": "integer", - "example": 1 - } - } - }, - "plan.TaskRequest": { - "type": "object", - "properties": { - "description": { - "type": "string", - "example": "打开1号风扇" - }, - "execution_order": { - "type": "integer", - "example": 1 - }, - "name": { - "type": "string", - "example": "打开风扇" - }, - "parameters": { - "type": "object", - "additionalProperties": true - }, - "type": { - "allOf": [ - { - "$ref": "#/definitions/models.TaskType" - } - ], - "example": "等待" - } - } - }, - "plan.TaskResponse": { - "type": "object", - "properties": { - "description": { - "type": "string", - "example": "打开1号风扇" - }, - "execution_order": { - "type": "integer", - "example": 1 - }, - "id": { - "type": "integer", - "example": 1 - }, - "name": { - "type": "string", - "example": "打开风扇" - }, - "parameters": { - "type": "object", - "additionalProperties": true - }, - "plan_id": { - "type": "integer", - "example": 1 - }, - "type": { - "allOf": [ - { - "$ref": "#/definitions/models.TaskType" - } - ], - "example": "等待" - } - } - }, - "plan.UpdatePlanRequest": { - "type": "object", - "properties": { - "cron_expression": { - "type": "string", - "example": "0 0 6 * * *" - }, - "description": { - "type": "string", - "example": "更新后的描述" - }, - "execute_num": { - "type": "integer", - "example": 10 - }, - "execution_type": { - "allOf": [ - { - "$ref": "#/definitions/models.PlanExecutionType" - } - ], - "example": "自动" - }, - "name": { - "type": "string", - "example": "猪舍温度控制计划V2" - }, - "sub_plan_ids": { - "type": "array", - "items": { - "type": "integer" - } - }, - "tasks": { - "type": "array", - "items": { - "$ref": "#/definitions/plan.TaskRequest" - } - } - } - }, - "user.CreateUserRequest": { - "type": "object", - "required": [ - "password", - "username" - ], - "properties": { - "password": { - "type": "string", - "example": "password123" - }, - "username": { - "type": "string", - "example": "newuser" - } - } - }, - "user.CreateUserResponse": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "example": 1 - }, - "username": { - "type": "string", - "example": "newuser" - } - } - }, - "user.HistoryResponse": { - "type": "object", - "properties": { - "action_type": { - "type": "string", - "example": "更新设备" - }, - "description": { - "type": "string", - "example": "设备更新成功" - }, - "target_resource": {}, - "time": { - "type": "string" - }, - "user_id": { - "type": "integer", - "example": 101 - }, - "username": { - "type": "string", - "example": "testuser" - } - } - }, - "user.ListHistoryResponse": { - "type": "object", - "properties": { - "history": { - "type": "array", - "items": { - "$ref": "#/definitions/user.HistoryResponse" - } - }, - "total": { - "type": "integer", - "example": 100 - } - } - }, - "user.LoginRequest": { - "type": "object", - "required": [ - "identifier", - "password" - ], - "properties": { - "identifier": { - "description": "Identifier 可以是用户名、邮箱、手机号、微信号或飞书账号", - "type": "string", - "example": "testuser" - }, - "password": { - "type": "string", - "example": "password123" - } - } - }, - "user.LoginResponse": { - "type": "object", - "properties": { - "id": { - "type": "integer", - "example": 1 - }, - "token": { - "type": "string", - "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." - }, - "username": { - "type": "string", - "example": "testuser" - } - } - } - } -} \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml deleted file mode 100644 index 2e66b9f..0000000 --- a/docs/swagger.yaml +++ /dev/null @@ -1,1193 +0,0 @@ -definitions: - controller.Response: - properties: - code: - allOf: - - $ref: '#/definitions/controller.ResponseCode' - description: 业务状态码 - data: - description: 业务数据 - message: - description: 提示信息 - type: string - type: object - controller.ResponseCode: - enum: - - 2000 - - 2001 - - 4000 - - 4001 - - 4004 - - 4009 - - 5000 - - 5003 - type: integer - x-enum-comments: - CodeBadRequest: 请求参数错误 - CodeConflict: 资源冲突 - CodeCreated: 创建成功 - CodeInternalError: 服务器内部错误 - CodeNotFound: 资源未找到 - CodeServiceUnavailable: 服务不可用 - CodeSuccess: 操作成功 - CodeUnauthorized: 未授权 - x-enum-descriptions: - - 操作成功 - - 创建成功 - - 请求参数错误 - - 未授权 - - 资源未找到 - - 资源冲突 - - 服务器内部错误 - - 服务不可用 - x-enum-varnames: - - CodeSuccess - - CodeCreated - - CodeBadRequest - - CodeUnauthorized - - CodeNotFound - - CodeConflict - - CodeInternalError - - CodeServiceUnavailable - device.AreaControllerResponse: - properties: - created_at: - type: string - id: - type: integer - location: - type: string - name: - type: string - network_id: - type: string - properties: - additionalProperties: true - type: object - status: - type: string - updated_at: - type: string - type: object - device.CreateAreaControllerRequest: - properties: - location: - type: string - name: - type: string - network_id: - type: string - properties: - additionalProperties: true - type: object - required: - - name - - network_id - type: object - device.CreateDeviceRequest: - properties: - area_controller_id: - type: integer - device_template_id: - type: integer - location: - type: string - name: - type: string - properties: - additionalProperties: true - type: object - required: - - area_controller_id - - 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: - type: string - name: - type: string - network_id: - type: string - properties: - additionalProperties: true - type: object - required: - - name - - network_id - type: object - device.UpdateDeviceRequest: - properties: - area_controller_id: - type: integer - device_template_id: - type: integer - location: - type: string - name: - type: string - properties: - additionalProperties: true - type: object - required: - - area_controller_id - - 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: - type: integer - area_controller_name: - type: string - created_at: - type: string - device_template_id: - type: integer - device_template_name: - type: string - id: - type: integer - location: - type: string - name: - type: string - properties: - additionalProperties: true - type: object - updated_at: - type: string - type: object - models.DeviceCategory: - enum: - - 执行器 - - 传感器 - type: string - x-enum-varnames: - - CategoryActuator - - CategorySensor - models.PlanContentType: - enum: - - 子计划 - - 任务 - type: string - x-enum-comments: - PlanContentTypeSubPlans: 计划包含子计划 - PlanContentTypeTasks: 计划包含任务 - x-enum-descriptions: - - 计划包含子计划 - - 计划包含任务 - x-enum-varnames: - - PlanContentTypeSubPlans - - PlanContentTypeTasks - models.PlanExecutionType: - enum: - - 自动 - - 手动 - type: string - x-enum-comments: - PlanExecutionTypeAutomatic: 自动执行 (包含定时和循环) - PlanExecutionTypeManual: 手动执行 - x-enum-descriptions: - - 自动执行 (包含定时和循环) - - 手动执行 - x-enum-varnames: - - PlanExecutionTypeAutomatic - - PlanExecutionTypeManual - models.PlanStatus: - enum: - - 已禁用 - - 已启用 - - 执行完毕 - - 执行失败 - type: string - x-enum-comments: - PlanStatusDisabled: 禁用计划 - PlanStatusEnabled: 启用计划 - PlanStatusFailed: 执行失败 - PlanStatusStopped: 执行完毕 - x-enum-descriptions: - - 禁用计划 - - 启用计划 - - 执行完毕 - - 执行失败 - x-enum-varnames: - - PlanStatusDisabled - - PlanStatusEnabled - - PlanStatusStopped - - PlanStatusFailed - models.SensorType: - enum: - - 信号强度 - - 电池电量 - - 温度 - - 湿度 - - 重量 - type: string - x-enum-comments: - SensorTypeBatteryLevel: 电池电量 - SensorTypeHumidity: 湿度 - SensorTypeSignalMetrics: 信号强度 - SensorTypeTemperature: 温度 - SensorTypeWeight: 重量 - x-enum-descriptions: - - 信号强度 - - 电池电量 - - 温度 - - 湿度 - - 重量 - x-enum-varnames: - - SensorTypeSignalMetrics - - SensorTypeBatteryLevel - - SensorTypeTemperature - - SensorTypeHumidity - - SensorTypeWeight - models.TaskType: - enum: - - 计划分析 - - 等待 - - 下料 - type: string - x-enum-comments: - TaskPlanAnalysis: 解析Plan的Task列表并添加到待执行队列的特殊任务 - TaskTypeReleaseFeedWeight: 下料口释放指定重量任务 - TaskTypeWaiting: 等待任务 - x-enum-descriptions: - - 解析Plan的Task列表并添加到待执行队列的特殊任务 - - 等待任务 - - 下料口释放指定重量任务 - x-enum-varnames: - - 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: - example: 0 0 6 * * * - type: string - description: - example: 根据温度自动调节风扇和加热器 - type: string - execute_num: - example: 10 - type: integer - execution_type: - allOf: - - $ref: '#/definitions/models.PlanExecutionType' - example: 自动 - name: - example: 猪舍温度控制计划 - type: string - sub_plan_ids: - items: - type: integer - type: array - tasks: - items: - $ref: '#/definitions/plan.TaskRequest' - type: array - required: - - execution_type - - name - type: object - plan.ListPlansResponse: - properties: - plans: - items: - $ref: '#/definitions/plan.PlanResponse' - type: array - total: - example: 100 - type: integer - type: object - plan.PlanResponse: - properties: - content_type: - allOf: - - $ref: '#/definitions/models.PlanContentType' - example: 任务 - cron_expression: - example: 0 0 6 * * * - type: string - description: - example: 根据温度自动调节风扇和加热器 - type: string - execute_count: - example: 0 - type: integer - execute_num: - example: 10 - type: integer - execution_type: - allOf: - - $ref: '#/definitions/models.PlanExecutionType' - example: 自动 - id: - example: 1 - type: integer - name: - example: 猪舍温度控制计划 - type: string - status: - allOf: - - $ref: '#/definitions/models.PlanStatus' - example: 已启用 - sub_plans: - items: - $ref: '#/definitions/plan.SubPlanResponse' - type: array - tasks: - items: - $ref: '#/definitions/plan.TaskResponse' - type: array - type: object - plan.SubPlanResponse: - properties: - child_plan: - $ref: '#/definitions/plan.PlanResponse' - child_plan_id: - example: 2 - type: integer - execution_order: - example: 1 - type: integer - id: - example: 1 - type: integer - parent_plan_id: - example: 1 - type: integer - type: object - plan.TaskRequest: - properties: - description: - example: 打开1号风扇 - type: string - execution_order: - example: 1 - type: integer - name: - example: 打开风扇 - type: string - parameters: - additionalProperties: true - type: object - type: - allOf: - - $ref: '#/definitions/models.TaskType' - example: 等待 - type: object - plan.TaskResponse: - properties: - description: - example: 打开1号风扇 - type: string - execution_order: - example: 1 - type: integer - id: - example: 1 - type: integer - name: - example: 打开风扇 - type: string - parameters: - additionalProperties: true - type: object - plan_id: - example: 1 - type: integer - type: - allOf: - - $ref: '#/definitions/models.TaskType' - example: 等待 - type: object - plan.UpdatePlanRequest: - properties: - cron_expression: - example: 0 0 6 * * * - type: string - description: - example: 更新后的描述 - type: string - execute_num: - example: 10 - type: integer - execution_type: - allOf: - - $ref: '#/definitions/models.PlanExecutionType' - example: 自动 - name: - example: 猪舍温度控制计划V2 - type: string - sub_plan_ids: - items: - type: integer - type: array - tasks: - items: - $ref: '#/definitions/plan.TaskRequest' - type: array - type: object - user.CreateUserRequest: - properties: - password: - example: password123 - type: string - username: - example: newuser - type: string - required: - - password - - username - type: object - user.CreateUserResponse: - properties: - id: - example: 1 - type: integer - username: - example: newuser - type: string - type: object - user.HistoryResponse: - properties: - action_type: - example: 更新设备 - type: string - description: - example: 设备更新成功 - type: string - target_resource: {} - time: - type: string - user_id: - example: 101 - type: integer - username: - example: testuser - type: string - type: object - user.ListHistoryResponse: - properties: - history: - items: - $ref: '#/definitions/user.HistoryResponse' - type: array - total: - example: 100 - type: integer - type: object - user.LoginRequest: - properties: - identifier: - description: Identifier 可以是用户名、邮箱、手机号、微信号或飞书账号 - example: testuser - type: string - password: - example: password123 - type: string - required: - - identifier - - password - type: object - user.LoginResponse: - properties: - id: - example: 1 - type: integer - token: - example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... - type: string - username: - example: testuser - type: string - type: object -info: - contact: {} -paths: - /api/v1/area-controllers: - get: - description: 获取系统中所有区域主控的列表 - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/controller.Response' - - properties: - data: - items: - $ref: '#/definitions/device.AreaControllerResponse' - type: array - type: object - summary: 获取所有区域主控列表 - tags: - - 区域主控管理 - post: - consumes: - - application/json - description: 根据提供的信息创建一个新区域主控 - parameters: - - description: 区域主控信息 - in: body - name: areaController - required: true - schema: - $ref: '#/definitions/device.CreateAreaControllerRequest' - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/controller.Response' - - properties: - data: - $ref: '#/definitions/device.AreaControllerResponse' - type: object - summary: 创建新区域主控 - tags: - - 区域主控管理 - /api/v1/area-controllers/{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.AreaControllerResponse' - 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: areaController - required: true - schema: - $ref: '#/definitions/device.UpdateAreaControllerRequest' - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/controller.Response' - - properties: - data: - $ref: '#/definitions/device.AreaControllerResponse' - type: object - 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: 获取系统中所有设备的列表 - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/controller.Response' - - properties: - data: - items: - $ref: '#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse' - type: array - type: object - summary: 获取设备列表 - tags: - - 设备管理 - post: - consumes: - - application/json - description: 根据提供的信息创建一个新设备 - parameters: - - description: 设备信息 - in: body - name: device - required: true - schema: - $ref: '#/definitions/device.CreateDeviceRequest' - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/controller.Response' - - properties: - data: - $ref: '#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse' - type: object - summary: 创建新设备 - tags: - - 设备管理 - /api/v1/devices/{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/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse' - 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: device - required: true - schema: - $ref: '#/definitions/device.UpdateDeviceRequest' - produces: - - application/json - responses: - "200": - description: OK - schema: - allOf: - - $ref: '#/definitions/controller.Response' - - properties: - data: - $ref: '#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse' - type: object - summary: 更新设备信息 - tags: - - 设备管理 - /api/v1/plans: - get: - description: 获取所有计划的列表 - produces: - - application/json - responses: - "200": - description: 业务码为200代表成功获取列表 - schema: - allOf: - - $ref: '#/definitions/controller.Response' - - properties: - data: - $ref: '#/definitions/plan.ListPlansResponse' - type: object - summary: 获取计划列表 - tags: - - 计划管理 - post: - consumes: - - application/json - description: 创建一个新的计划,包括其基本信息和所有关联的子计划/任务。 - parameters: - - description: 计划信息 - in: body - name: plan - required: true - schema: - $ref: '#/definitions/plan.CreatePlanRequest' - produces: - - application/json - responses: - "200": - description: 业务码为201代表创建成功 - schema: - allOf: - - $ref: '#/definitions/controller.Response' - - properties: - data: - $ref: '#/definitions/plan.PlanResponse' - type: object - summary: 创建计划 - tags: - - 计划管理 - /api/v1/plans/{id}: - delete: - description: 根据计划ID删除计划。(软删除) - parameters: - - description: 计划ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: 业务码为200代表删除成功 - schema: - $ref: '#/definitions/controller.Response' - summary: 删除计划 - tags: - - 计划管理 - get: - description: 根据计划ID获取单个计划的详细信息。 - parameters: - - description: 计划ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: 业务码为200代表成功获取 - schema: - allOf: - - $ref: '#/definitions/controller.Response' - - properties: - data: - $ref: '#/definitions/plan.PlanResponse' - type: object - summary: 获取计划详情 - tags: - - 计划管理 - put: - consumes: - - application/json - description: 根据计划ID更新计划的详细信息。 - parameters: - - description: 计划ID - in: path - name: id - required: true - type: integer - - description: 更新后的计划信息 - in: body - name: plan - required: true - schema: - $ref: '#/definitions/plan.UpdatePlanRequest' - produces: - - application/json - responses: - "200": - description: 业务码为200代表更新成功 - schema: - allOf: - - $ref: '#/definitions/controller.Response' - - properties: - data: - $ref: '#/definitions/plan.PlanResponse' - type: object - summary: 更新计划 - tags: - - 计划管理 - /api/v1/plans/{id}/start: - post: - description: 根据计划ID启动一个计划的执行。 - parameters: - - description: 计划ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: 业务码为200代表成功启动计划 - schema: - $ref: '#/definitions/controller.Response' - summary: 启动计划 - tags: - - 计划管理 - /api/v1/plans/{id}/stop: - post: - description: 根据计划ID停止一个正在执行的计划。 - parameters: - - description: 计划ID - in: path - name: id - required: true - type: integer - produces: - - application/json - responses: - "200": - description: 业务码为200代表成功停止计划 - schema: - $ref: '#/definitions/controller.Response' - summary: 停止计划 - tags: - - 计划管理 - /api/v1/users: - post: - consumes: - - application/json - description: 根据用户名和密码创建一个新的系统用户。 - parameters: - - description: 用户信息 - in: body - name: user - required: true - schema: - $ref: '#/definitions/user.CreateUserRequest' - produces: - - application/json - responses: - "200": - description: 业务码为201代表创建成功 - schema: - allOf: - - $ref: '#/definitions/controller.Response' - - properties: - data: - $ref: '#/definitions/user.CreateUserResponse' - type: object - summary: 创建新用户 - tags: - - 用户管理 - /api/v1/users/{id}/history: - get: - description: 根据用户ID,分页获取该用户的操作审计日志。 - parameters: - - description: 用户ID - in: path - name: id - required: true - type: integer - - default: 1 - description: 页码 - in: query - name: page - type: integer - - default: 10 - description: 每页大小 - in: query - name: page_size - type: integer - - description: 按操作类型过滤 - in: query - name: action_type - type: string - produces: - - application/json - responses: - "200": - description: 业务码为200代表成功获取 - schema: - allOf: - - $ref: '#/definitions/controller.Response' - - properties: - data: - $ref: '#/definitions/user.ListHistoryResponse' - type: object - summary: 获取指定用户的操作历史 - tags: - - 用户管理 - /api/v1/users/login: - post: - consumes: - - application/json - description: 用户可以使用用户名、邮箱、手机号、微信号或飞书账号进行登录,成功后返回 JWT 令牌。 - parameters: - - description: 登录凭证 - in: body - name: credentials - required: true - schema: - $ref: '#/definitions/user.LoginRequest' - produces: - - application/json - responses: - "200": - description: 业务码为200代表登录成功 - schema: - allOf: - - $ref: '#/definitions/controller.Response' - - properties: - data: - $ref: '#/definitions/user.LoginResponse' - type: object - summary: 用户登录 - tags: - - 用户管理 -swagger: "2.0" diff --git a/internal/app/api/api.go b/internal/app/api/api.go index 5758ab9..6c00efd 100644 --- a/internal/app/api/api.go +++ b/internal/app/api/api.go @@ -204,7 +204,7 @@ func (a *API) setupRoutes() { a.logger.Info("计划相关接口注册成功 (需要认证和审计)") // 猪舍相关路由组 - pigHouseGroup := authGroup.Group("/pighouses") + pigHouseGroup := authGroup.Group("/pig-houses") { pigHouseGroup.POST("", a.pigFarmController.CreatePigHouse) pigHouseGroup.GET("", a.pigFarmController.ListPigHouses) diff --git a/internal/app/controller/management/pig_farm_controller.go b/internal/app/controller/management/pig_farm_controller.go index 1dcc7b1..9f37005 100644 --- a/internal/app/controller/management/pig_farm_controller.go +++ b/internal/app/controller/management/pig_farm_controller.go @@ -38,7 +38,7 @@ func NewPigFarmController(logger *logs.Logger, service service.PigFarmService) * // @Produce json // @Param body body dto.CreatePigHouseRequest true "猪舍信息" // @Success 201 {object} controller.Response{data=dto.PigHouseResponse} "创建成功" -// @Router /api/v1/pighouses [post] +// @Router /api/v1/pig-houses [post] func (c *PigFarmController) CreatePigHouse(ctx *gin.Context) { const action = "创建猪舍" var req dto.CreatePigHouseRequest @@ -69,7 +69,7 @@ func (c *PigFarmController) CreatePigHouse(ctx *gin.Context) { // @Produce json // @Param id path int true "猪舍ID" // @Success 200 {object} controller.Response{data=dto.PigHouseResponse} "获取成功" -// @Router /api/v1/pighouses/{id} [get] +// @Router /api/v1/pig-houses/{id} [get] func (c *PigFarmController) GetPigHouse(ctx *gin.Context) { const action = "获取猪舍" id, err := strconv.ParseUint(ctx.Param("id"), 10, 32) @@ -103,7 +103,7 @@ func (c *PigFarmController) GetPigHouse(ctx *gin.Context) { // @Tags 猪场管理 // @Produce json // @Success 200 {object} controller.Response{data=[]dto.PigHouseResponse} "获取成功" -// @Router /api/v1/pighouses [get] +// @Router /api/v1/pig-houses [get] func (c *PigFarmController) ListPigHouses(ctx *gin.Context) { const action = "获取猪舍列表" houses, err := c.service.ListPigHouses() @@ -134,7 +134,7 @@ func (c *PigFarmController) ListPigHouses(ctx *gin.Context) { // @Param id path int true "猪舍ID" // @Param body body dto.UpdatePigHouseRequest true "猪舍信息" // @Success 200 {object} controller.Response{data=dto.PigHouseResponse} "更新成功" -// @Router /api/v1/pighouses/{id} [put] +// @Router /api/v1/pig-houses/{id} [put] func (c *PigFarmController) UpdatePigHouse(ctx *gin.Context) { const action = "更新猪舍" id, err := strconv.ParseUint(ctx.Param("id"), 10, 32) @@ -175,7 +175,7 @@ func (c *PigFarmController) UpdatePigHouse(ctx *gin.Context) { // @Produce json // @Param id path int true "猪舍ID" // @Success 200 {object} controller.Response "删除成功" -// @Router /api/v1/pighouses/{id} [delete] +// @Router /api/v1/pig-houses/{id} [delete] func (c *PigFarmController) DeletePigHouse(ctx *gin.Context) { const action = "删除猪舍" id, err := strconv.ParseUint(ctx.Param("id"), 10, 32) @@ -216,7 +216,7 @@ func (c *PigFarmController) CreatePen(ctx *gin.Context) { return } - pen, err := c.service.CreatePen(req.PenNumber, req.HouseID, req.Capacity, req.Status) + pen, err := c.service.CreatePen(req.PenNumber, req.HouseID, req.Capacity) if err != nil { c.logger.Errorf("%s: 业务逻辑失败: %v", action, err) controller.SendErrorWithAudit(ctx, controller.CodeInternalError, "创建猪栏失败", action, "业务逻辑失败", req) diff --git a/internal/app/service/pig_farm_service.go b/internal/app/service/pig_farm_service.go index 0461e01..433e5e3 100644 --- a/internal/app/service/pig_farm_service.go +++ b/internal/app/service/pig_farm_service.go @@ -26,7 +26,7 @@ type PigFarmService interface { DeletePigHouse(id uint) error // Pen methods - CreatePen(penNumber string, houseID uint, capacity int, status models.PenStatus) (*models.Pen, error) + CreatePen(penNumber string, houseID uint, capacity int) (*models.Pen, error) GetPenByID(id uint) (*models.Pen, error) ListPens() ([]models.Pen, error) UpdatePen(id uint, penNumber string, houseID uint, capacity int, status models.PenStatus) (*models.Pen, error) @@ -99,7 +99,7 @@ func (s *pigFarmService) DeletePigHouse(id uint) error { // --- Pen Implementation --- -func (s *pigFarmService) CreatePen(penNumber string, houseID uint, capacity int, status models.PenStatus) (*models.Pen, error) { +func (s *pigFarmService) CreatePen(penNumber string, houseID uint, capacity int) (*models.Pen, error) { // 业务逻辑:验证所属猪舍是否存在 _, err := s.repo.GetPigHouseByID(houseID) if err != nil { @@ -113,7 +113,7 @@ func (s *pigFarmService) CreatePen(penNumber string, houseID uint, capacity int, PenNumber: penNumber, HouseID: houseID, Capacity: capacity, - Status: status, + Status: models.PenStatusEmpty, } err = s.repo.CreatePen(pen) return pen, err