diff --git a/.gitignore b/.gitignore index a3cd171d..f6b102bf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,22 @@ -# ---> Vue -# gitignore template for Vue.js projects -# -# Recommended template: Node.gitignore +# Logs +npm-debug.log* +yarn-error.log* -# TODO: where does this rule come from? +# Dependencies +node_modules/ + +# Build output +dist/ + +# Environment variables +.env* +*.local + +# IDE config +.idea/ + +# Docs docs/_book -# TODO: where does this rule come from? +# Tests test/ - -.idea/ \ No newline at end of file diff --git a/docs/swagger.json b/docs/swagger.json index 112b3102..6b798e72 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -2,16 +2,29 @@ "schemes": [], "swagger": "2.0", "info": { - "description": "", - "title": "", - "contact": {}, - "version": "" + "description": "这是一个用于管理猪场设备的后端服务。", + "title": "猪场管理系统 API", + "contact": { + "name": "Divano", + "url": "http://www.example.com", + "email": "divano@example.com" + }, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version": "1.0" }, "host": "", "basePath": "", "paths": { "/api/v1/area-controllers": { "get": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "获取系统中所有区域主控的列表", "produces": [ "application/json" @@ -34,7 +47,7 @@ "data": { "type": "array", "items": { - "$ref": "#/definitions/device.AreaControllerResponse" + "$ref": "#/definitions/dto.AreaControllerResponse" } } } @@ -45,6 +58,11 @@ } }, "post": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "根据提供的信息创建一个新区域主控", "consumes": [ "application/json" @@ -63,7 +81,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/device.CreateAreaControllerRequest" + "$ref": "#/definitions/dto.CreateAreaControllerRequest" } } ], @@ -79,7 +97,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/device.AreaControllerResponse" + "$ref": "#/definitions/dto.AreaControllerResponse" } } } @@ -91,6 +109,11 @@ }, "/api/v1/area-controllers/{id}": { "get": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "根据ID获取单个区域主控的详细信息", "produces": [ "application/json" @@ -120,7 +143,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/device.AreaControllerResponse" + "$ref": "#/definitions/dto.AreaControllerResponse" } } } @@ -130,6 +153,11 @@ } }, "put": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "根据ID更新一个已存在的区域主控信息", "consumes": [ "application/json" @@ -155,7 +183,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/device.UpdateAreaControllerRequest" + "$ref": "#/definitions/dto.UpdateAreaControllerRequest" } } ], @@ -171,7 +199,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/device.AreaControllerResponse" + "$ref": "#/definitions/dto.AreaControllerResponse" } } } @@ -181,6 +209,11 @@ } }, "delete": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "根据ID删除一个区域主控(软删除)", "produces": [ "application/json" @@ -210,6 +243,11 @@ }, "/api/v1/device-templates": { "get": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "获取系统中所有设备模板的列表", "produces": [ "application/json" @@ -232,7 +270,7 @@ "data": { "type": "array", "items": { - "$ref": "#/definitions/device.DeviceTemplateResponse" + "$ref": "#/definitions/dto.DeviceTemplateResponse" } } } @@ -243,6 +281,11 @@ } }, "post": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "根据提供的信息创建一个新设备模板", "consumes": [ "application/json" @@ -261,7 +304,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/device.CreateDeviceTemplateRequest" + "$ref": "#/definitions/dto.CreateDeviceTemplateRequest" } } ], @@ -277,7 +320,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/device.DeviceTemplateResponse" + "$ref": "#/definitions/dto.DeviceTemplateResponse" } } } @@ -289,6 +332,11 @@ }, "/api/v1/device-templates/{id}": { "get": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "根据设备模板ID获取单个设备模板的详细信息", "produces": [ "application/json" @@ -318,7 +366,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/device.DeviceTemplateResponse" + "$ref": "#/definitions/dto.DeviceTemplateResponse" } } } @@ -328,6 +376,11 @@ } }, "put": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "根据设备模板ID更新一个已存在的设备模板信息", "consumes": [ "application/json" @@ -353,7 +406,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/device.UpdateDeviceTemplateRequest" + "$ref": "#/definitions/dto.UpdateDeviceTemplateRequest" } } ], @@ -369,7 +422,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/device.DeviceTemplateResponse" + "$ref": "#/definitions/dto.DeviceTemplateResponse" } } } @@ -379,6 +432,11 @@ } }, "delete": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "根据设备模板ID删除一个设备模板(软删除)", "produces": [ "application/json" @@ -408,6 +466,11 @@ }, "/api/v1/devices": { "get": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "获取系统中所有设备的列表", "produces": [ "application/json" @@ -430,7 +493,7 @@ "data": { "type": "array", "items": { - "$ref": "#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse" + "$ref": "#/definitions/dto.DeviceResponse" } } } @@ -441,6 +504,11 @@ } }, "post": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "根据提供的信息创建一个新设备", "consumes": [ "application/json" @@ -459,7 +527,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/device.CreateDeviceRequest" + "$ref": "#/definitions/dto.CreateDeviceRequest" } } ], @@ -475,7 +543,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse" + "$ref": "#/definitions/dto.DeviceResponse" } } } @@ -485,8 +553,59 @@ } } }, + "/api/v1/devices/manual-control/{id}": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据设备ID和指定的动作(开启或关闭)来手动控制设备", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "设备管理" + ], + "summary": "手动控制设备", + "parameters": [ + { + "type": "string", + "description": "设备ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "手动控制指令", + "name": "manualControl", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.ManualControlDeviceRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, "/api/v1/devices/{id}": { "get": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "根据设备ID获取单个设备的详细信息", "produces": [ "application/json" @@ -516,7 +635,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse" + "$ref": "#/definitions/dto.DeviceResponse" } } } @@ -526,6 +645,11 @@ } }, "put": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "根据设备ID更新一个已存在的设备信息", "consumes": [ "application/json" @@ -551,7 +675,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/device.UpdateDeviceRequest" + "$ref": "#/definitions/dto.UpdateDeviceRequest" } } ], @@ -567,7 +691,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/git_huangwc_com_pig_pig-farm-controller_internal_app_controller_device.DeviceResponse" + "$ref": "#/definitions/dto.DeviceResponse" } } } @@ -577,6 +701,11 @@ } }, "delete": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "根据设备ID删除一个设备(软删除)", "produces": [ "application/json" @@ -604,8 +733,2725 @@ } } }, + "/api/v1/monitor/device-command-logs": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据提供的过滤条件,分页获取设备命令日志", + "produces": [ + "application/json" + ], + "tags": [ + "数据监控" + ], + "summary": "获取设备命令日志列表", + "parameters": [ + { + "type": "integer", + "name": "device_id", + "in": "query" + }, + { + "type": "string", + "name": "end_time", + "in": "query" + }, + { + "type": "string", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "pageSize", + "in": "query" + }, + { + "type": "boolean", + "name": "received_success", + "in": "query" + }, + { + "type": "string", + "name": "start_time", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListDeviceCommandLogResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/monitor/feed-usage-records": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据提供的过滤条件,分页获取饲料使用记录", + "produces": [ + "application/json" + ], + "tags": [ + "数据监控" + ], + "summary": "获取饲料使用记录列表", + "parameters": [ + { + "type": "string", + "name": "end_time", + "in": "query" + }, + { + "type": "integer", + "name": "feed_formula_id", + "in": "query" + }, + { + "type": "integer", + "name": "operator_id", + "in": "query" + }, + { + "type": "string", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "pageSize", + "in": "query" + }, + { + "type": "integer", + "name": "pen_id", + "in": "query" + }, + { + "type": "string", + "name": "start_time", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListFeedUsageRecordResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/monitor/medication-logs": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据提供的过滤条件,分页获取用药记录", + "produces": [ + "application/json" + ], + "tags": [ + "数据监控" + ], + "summary": "获取用药记录列表", + "parameters": [ + { + "type": "string", + "name": "end_time", + "in": "query" + }, + { + "type": "integer", + "name": "medication_id", + "in": "query" + }, + { + "type": "integer", + "name": "operator_id", + "in": "query" + }, + { + "type": "string", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "pageSize", + "in": "query" + }, + { + "type": "integer", + "name": "pig_batch_id", + "in": "query" + }, + { + "type": "string", + "name": "reason", + "in": "query" + }, + { + "type": "string", + "name": "start_time", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListMedicationLogResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/monitor/pending-collections": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据提供的过滤条件,分页获取待采集请求", + "produces": [ + "application/json" + ], + "tags": [ + "数据监控" + ], + "summary": "获取待采集请求列表", + "parameters": [ + { + "type": "integer", + "name": "device_id", + "in": "query" + }, + { + "type": "string", + "name": "end_time", + "in": "query" + }, + { + "type": "string", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "pageSize", + "in": "query" + }, + { + "type": "string", + "name": "start_time", + "in": "query" + }, + { + "type": "string", + "name": "status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListPendingCollectionResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/monitor/pig-batch-logs": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据提供的过滤条件,分页获取猪批次日志", + "produces": [ + "application/json" + ], + "tags": [ + "数据监控" + ], + "summary": "获取猪批次日志列表", + "parameters": [ + { + "type": "string", + "name": "change_type", + "in": "query" + }, + { + "type": "string", + "name": "end_time", + "in": "query" + }, + { + "type": "integer", + "name": "operator_id", + "in": "query" + }, + { + "type": "string", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "pageSize", + "in": "query" + }, + { + "type": "integer", + "name": "pig_batch_id", + "in": "query" + }, + { + "type": "string", + "name": "start_time", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListPigBatchLogResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/monitor/pig-purchases": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据提供的过滤条件,分页获取猪只采购记录", + "produces": [ + "application/json" + ], + "tags": [ + "数据监控" + ], + "summary": "获取猪只采购记录列表", + "parameters": [ + { + "type": "string", + "name": "end_time", + "in": "query" + }, + { + "type": "integer", + "name": "operator_id", + "in": "query" + }, + { + "type": "string", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "pageSize", + "in": "query" + }, + { + "type": "integer", + "name": "pig_batch_id", + "in": "query" + }, + { + "type": "string", + "name": "start_time", + "in": "query" + }, + { + "type": "string", + "name": "supplier", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListPigPurchaseResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/monitor/pig-sales": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据提供的过滤条件,分页获取猪只售卖记录", + "produces": [ + "application/json" + ], + "tags": [ + "数据监控" + ], + "summary": "获取猪只售卖记录列表", + "parameters": [ + { + "type": "string", + "name": "buyer", + "in": "query" + }, + { + "type": "string", + "name": "end_time", + "in": "query" + }, + { + "type": "integer", + "name": "operator_id", + "in": "query" + }, + { + "type": "string", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "pageSize", + "in": "query" + }, + { + "type": "integer", + "name": "pig_batch_id", + "in": "query" + }, + { + "type": "string", + "name": "start_time", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListPigSaleResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/monitor/pig-sick-logs": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据提供的过滤条件,分页获取病猪日志", + "produces": [ + "application/json" + ], + "tags": [ + "数据监控" + ], + "summary": "获取病猪日志列表", + "parameters": [ + { + "type": "string", + "name": "end_time", + "in": "query" + }, + { + "type": "integer", + "name": "operator_id", + "in": "query" + }, + { + "type": "string", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "pageSize", + "in": "query" + }, + { + "type": "integer", + "name": "pen_id", + "in": "query" + }, + { + "type": "integer", + "name": "pig_batch_id", + "in": "query" + }, + { + "type": "string", + "name": "reason", + "in": "query" + }, + { + "type": "string", + "name": "start_time", + "in": "query" + }, + { + "type": "string", + "name": "treatment_location", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListPigSickLogResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/monitor/pig-transfer-logs": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据提供的过滤条件,分页获取猪只迁移日志", + "produces": [ + "application/json" + ], + "tags": [ + "数据监控" + ], + "summary": "获取猪只迁移日志列表", + "parameters": [ + { + "type": "string", + "name": "correlation_id", + "in": "query" + }, + { + "type": "string", + "name": "end_time", + "in": "query" + }, + { + "type": "integer", + "name": "operator_id", + "in": "query" + }, + { + "type": "string", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "pageSize", + "in": "query" + }, + { + "type": "integer", + "name": "pen_id", + "in": "query" + }, + { + "type": "integer", + "name": "pig_batch_id", + "in": "query" + }, + { + "type": "string", + "name": "start_time", + "in": "query" + }, + { + "type": "string", + "name": "transfer_type", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListPigTransferLogResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/monitor/plan-execution-logs": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据提供的过滤条件,分页获取计划执行日志", + "produces": [ + "application/json" + ], + "tags": [ + "数据监控" + ], + "summary": "获取计划执行日志列表", + "parameters": [ + { + "type": "string", + "name": "end_time", + "in": "query" + }, + { + "type": "string", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "pageSize", + "in": "query" + }, + { + "type": "integer", + "name": "plan_id", + "in": "query" + }, + { + "type": "string", + "name": "start_time", + "in": "query" + }, + { + "type": "string", + "name": "status", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListPlanExecutionLogResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/monitor/raw-material-purchases": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据提供的过滤条件,分页获取原料采购记录", + "produces": [ + "application/json" + ], + "tags": [ + "数据监控" + ], + "summary": "获取原料采购记录列表", + "parameters": [ + { + "type": "string", + "name": "end_time", + "in": "query" + }, + { + "type": "string", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "pageSize", + "in": "query" + }, + { + "type": "integer", + "name": "raw_material_id", + "in": "query" + }, + { + "type": "string", + "name": "start_time", + "in": "query" + }, + { + "type": "string", + "name": "supplier", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListRawMaterialPurchaseResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/monitor/raw-material-stock-logs": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据提供的过滤条件,分页获取原料库存日志", + "produces": [ + "application/json" + ], + "tags": [ + "数据监控" + ], + "summary": "获取原料库存日志列表", + "parameters": [ + { + "type": "string", + "name": "end_time", + "in": "query" + }, + { + "type": "string", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "pageSize", + "in": "query" + }, + { + "type": "integer", + "name": "raw_material_id", + "in": "query" + }, + { + "type": "integer", + "name": "source_id", + "in": "query" + }, + { + "type": "string", + "name": "source_type", + "in": "query" + }, + { + "type": "string", + "name": "start_time", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListRawMaterialStockLogResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/monitor/sensor-data": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据提供的过滤条件,分页获取传感器数据", + "produces": [ + "application/json" + ], + "tags": [ + "数据监控" + ], + "summary": "获取传感器数据列表", + "parameters": [ + { + "type": "integer", + "name": "device_id", + "in": "query" + }, + { + "type": "string", + "name": "end_time", + "in": "query" + }, + { + "type": "string", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "pageSize", + "in": "query" + }, + { + "type": "string", + "name": "sensor_type", + "in": "query" + }, + { + "type": "string", + "name": "start_time", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListSensorDataResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/monitor/task-execution-logs": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据提供的过滤条件,分页获取任务执行日志", + "produces": [ + "application/json" + ], + "tags": [ + "数据监控" + ], + "summary": "获取任务执行日志列表", + "parameters": [ + { + "type": "string", + "name": "end_time", + "in": "query" + }, + { + "type": "string", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "pageSize", + "in": "query" + }, + { + "type": "integer", + "name": "plan_execution_log_id", + "in": "query" + }, + { + "type": "string", + "name": "start_time", + "in": "query" + }, + { + "type": "string", + "name": "status", + "in": "query" + }, + { + "type": "integer", + "name": "task_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListTaskExecutionLogResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/monitor/user-action-logs": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据提供的过滤条件,分页获取用户操作日志", + "produces": [ + "application/json" + ], + "tags": [ + "数据监控" + ], + "summary": "获取用户操作日志列表", + "parameters": [ + { + "type": "string", + "name": "action_type", + "in": "query" + }, + { + "type": "string", + "name": "end_time", + "in": "query" + }, + { + "type": "string", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "pageSize", + "in": "query" + }, + { + "type": "string", + "name": "start_time", + "in": "query" + }, + { + "type": "string", + "name": "status", + "in": "query" + }, + { + "type": "integer", + "name": "user_id", + "in": "query" + }, + { + "type": "string", + "name": "username", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListUserActionLogResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/monitor/weighing-batches": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据提供的过滤条件,分页获取批次称重记录", + "produces": [ + "application/json" + ], + "tags": [ + "数据监控" + ], + "summary": "获取批次称重记录列表", + "parameters": [ + { + "type": "string", + "name": "end_time", + "in": "query" + }, + { + "type": "string", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "pageSize", + "in": "query" + }, + { + "type": "integer", + "name": "pig_batch_id", + "in": "query" + }, + { + "type": "string", + "name": "start_time", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListWeighingBatchResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/monitor/weighing-records": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据提供的过滤条件,分页获取单次称重记录", + "produces": [ + "application/json" + ], + "tags": [ + "数据监控" + ], + "summary": "获取单次称重记录列表", + "parameters": [ + { + "type": "string", + "name": "end_time", + "in": "query" + }, + { + "type": "integer", + "name": "operator_id", + "in": "query" + }, + { + "type": "string", + "name": "order_by", + "in": "query" + }, + { + "type": "integer", + "name": "page", + "in": "query" + }, + { + "type": "integer", + "name": "pageSize", + "in": "query" + }, + { + "type": "integer", + "name": "pen_id", + "in": "query" + }, + { + "type": "string", + "name": "start_time", + "in": "query" + }, + { + "type": "integer", + "name": "weighing_batch_id", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.ListWeighingRecordResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/pens": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "获取所有猪栏的列表", + "produces": [ + "application/json" + ], + "tags": [ + "猪场管理" + ], + "summary": "获取猪栏列表", + "responses": { + "200": { + "description": "获取成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.PenResponse" + } + } + } + } + ] + } + } + } + }, + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "创建一个新的猪栏", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪场管理" + ], + "summary": "创建猪栏", + "parameters": [ + { + "description": "猪栏信息", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.CreatePenRequest" + } + } + ], + "responses": { + "201": { + "description": "创建成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PenResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/pens/{id}": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID获取单个猪栏信息", + "produces": [ + "application/json" + ], + "tags": [ + "猪场管理" + ], + "summary": "获取单个猪栏", + "parameters": [ + { + "type": "integer", + "description": "猪栏ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "获取成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PenResponse" + } + } + } + ] + } + } + } + }, + "put": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "更新一个已存在的猪栏信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪场管理" + ], + "summary": "更新猪栏", + "parameters": [ + { + "type": "integer", + "description": "猪栏ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "猪栏信息", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.UpdatePenRequest" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PenResponse" + } + } + } + ] + } + } + } + }, + "delete": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID删除一个猪栏", + "produces": [ + "application/json" + ], + "tags": [ + "猪场管理" + ], + "summary": "删除猪栏", + "parameters": [ + { + "type": "integer", + "description": "猪栏ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/pens/{id}/status": { + "put": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "更新指定猪栏的当前状态", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪场管理" + ], + "summary": "更新猪栏状态", + "parameters": [ + { + "type": "integer", + "description": "猪栏ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "新的猪栏状态", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.UpdatePenStatusRequest" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PenResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/pig-batches": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "获取所有猪批次的列表,支持按活跃状态筛选", + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "获取猪批次列表", + "parameters": [ + { + "type": "boolean", + "description": "是否活跃 (true/false)", + "name": "is_active", + "in": "query" + } + ], + "responses": { + "200": { + "description": "获取成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.PigBatchResponseDTO" + } + } + } + } + ] + } + } + } + }, + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "创建一个新的猪批次", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "创建猪批次", + "parameters": [ + { + "description": "猪批次信息", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.PigBatchCreateDTO" + } + } + ], + "responses": { + "201": { + "description": "创建成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PigBatchResponseDTO" + } + } + } + ] + } + } + } + } + }, + "/api/v1/pig-batches/assign-pens/{id}": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "将一个或多个空闲猪栏分配给指定的猪批次", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "为猪批次分配空栏", + "parameters": [ + { + "type": "integer", + "description": "猪批次ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "待分配的猪栏ID列表", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.AssignEmptyPensToBatchRequest" + } + } + ], + "responses": { + "200": { + "description": "分配成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/pig-batches/buy-pigs/{id}": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "记录猪批次中的猪只购买事件", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "处理买猪的业务逻辑", + "parameters": [ + { + "type": "integer", + "description": "猪批次ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "买猪请求信息", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.BuyPigsRequest" + } + } + ], + "responses": { + "200": { + "description": "买猪成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/pig-batches/move-pigs-into-pen/{id}": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "将指定数量的猪只从批次的“虚拟库存”移入一个已分配的猪栏", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "将猪只从“虚拟库存”移入指定猪栏", + "parameters": [ + { + "type": "integer", + "description": "猪批次ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "移入猪只请求信息 (包含目标猪栏ID、数量和备注)", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.MovePigsIntoPenRequest" + } + } + ], + "responses": { + "200": { + "description": "移入成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/pig-batches/reclassify-pen/{fromBatchID}": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "将一个猪栏(连同其中的猪只)从一个批次整体划拨到另一个批次", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "将猪栏划拨到新批次", + "parameters": [ + { + "type": "integer", + "description": "源猪批次ID", + "name": "fromBatchID", + "in": "path", + "required": true + }, + { + "description": "划拨请求信息 (包含目标批次ID、猪栏ID和备注)", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.ReclassifyPenToNewBatchRequest" + } + } + ], + "responses": { + "200": { + "description": "划拨成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/pig-batches/record-cull/{id}": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "记录猪批次中正常猪只淘汰的数量和发生时间", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "记录正常猪只淘汰事件", + "parameters": [ + { + "type": "integer", + "description": "猪批次ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "记录正常猪只淘汰请求信息", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.RecordCullRequest" + } + } + ], + "responses": { + "200": { + "description": "记录成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/pig-batches/record-death/{id}": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "记录猪批次中正常猪只死亡的数量和发生时间", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "记录正常猪只死亡事件", + "parameters": [ + { + "type": "integer", + "description": "猪批次ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "记录正常猪只死亡请求信息", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.RecordDeathRequest" + } + } + ], + "responses": { + "200": { + "description": "记录成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/pig-batches/record-sick-pig-cull/{id}": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "记录猪批次中病猪淘汰的数量、治疗地点和发生时间", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "记录病猪淘汰事件", + "parameters": [ + { + "type": "integer", + "description": "猪批次ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "记录病猪淘汰请求信息", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.RecordSickPigCullRequest" + } + } + ], + "responses": { + "200": { + "description": "记录成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/pig-batches/record-sick-pig-death/{id}": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "记录猪批次中病猪死亡的数量、治疗地点和发生时间", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "记录病猪死亡事件", + "parameters": [ + { + "type": "integer", + "description": "猪批次ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "记录病猪死亡请求信息", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.RecordSickPigDeathRequest" + } + } + ], + "responses": { + "200": { + "description": "记录成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/pig-batches/record-sick-pig-recovery/{id}": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "记录猪批次中病猪康复的数量、治疗地点和发生时间", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "记录病猪康复事件", + "parameters": [ + { + "type": "integer", + "description": "猪批次ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "记录病猪康复请求信息", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.RecordSickPigRecoveryRequest" + } + } + ], + "responses": { + "200": { + "description": "记录成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/pig-batches/record-sick-pigs/{id}": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "记录猪批次中新增病猪的数量、治疗地点和发生时间", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "记录新增病猪事件", + "parameters": [ + { + "type": "integer", + "description": "猪批次ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "记录病猪请求信息", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.RecordSickPigsRequest" + } + } + ], + "responses": { + "200": { + "description": "记录成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/pig-batches/remove-pen/{penID}/{batchID}": { + "delete": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "将一个空闲猪栏从指定的猪批次中移除", + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "从猪批次移除空栏", + "parameters": [ + { + "type": "integer", + "description": "猪批次ID", + "name": "batchID", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "待移除的猪栏ID", + "name": "penID", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "移除成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/pig-batches/sell-pigs/{id}": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "记录猪批次中的猪只出售事件", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "处理卖猪的业务逻辑", + "parameters": [ + { + "type": "integer", + "description": "猪批次ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "卖猪请求信息", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.SellPigsRequest" + } + } + ], + "responses": { + "200": { + "description": "卖猪成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/pig-batches/transfer-across-batches/{sourceBatchID}": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "将指定数量的猪只从一个猪群的猪栏调动到另一个猪群的猪栏", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "跨猪群调栏", + "parameters": [ + { + "type": "integer", + "description": "源猪批次ID", + "name": "sourceBatchID", + "in": "path", + "required": true + }, + { + "description": "跨群调栏请求信息", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.TransferPigsAcrossBatchesRequest" + } + } + ], + "responses": { + "200": { + "description": "调栏成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/pig-batches/transfer-within-batch/{id}": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "将指定数量的猪只在同一个猪群的不同猪栏间调动", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "群内调栏", + "parameters": [ + { + "type": "integer", + "description": "猪批次ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "群内调栏请求信息", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.TransferPigsWithinBatchRequest" + } + } + ], + "responses": { + "200": { + "description": "调栏成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/pig-batches/{id}": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID获取单个猪批次信息", + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "获取单个猪批次", + "parameters": [ + { + "type": "integer", + "description": "猪批次ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "获取成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PigBatchResponseDTO" + } + } + } + ] + } + } + } + }, + "put": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "更新一个已存在的猪批次信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "更新猪批次", + "parameters": [ + { + "type": "integer", + "description": "猪批次ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "猪批次信息", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.PigBatchUpdateDTO" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PigBatchResponseDTO" + } + } + } + ] + } + } + } + }, + "delete": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID删除一个猪批次", + "produces": [ + "application/json" + ], + "tags": [ + "猪群管理" + ], + "summary": "删除猪批次", + "parameters": [ + { + "type": "integer", + "description": "猪批次ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, + "/api/v1/pig-houses": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "获取所有猪舍的列表", + "produces": [ + "application/json" + ], + "tags": [ + "猪场管理" + ], + "summary": "获取猪舍列表", + "responses": { + "200": { + "description": "获取成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.PigHouseResponse" + } + } + } + } + ] + } + } + } + }, + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "创建一个新的猪舍", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪场管理" + ], + "summary": "创建猪舍", + "parameters": [ + { + "description": "猪舍信息", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.CreatePigHouseRequest" + } + } + ], + "responses": { + "201": { + "description": "创建成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PigHouseResponse" + } + } + } + ] + } + } + } + } + }, + "/api/v1/pig-houses/{id}": { + "get": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID获取单个猪舍信息", + "produces": [ + "application/json" + ], + "tags": [ + "猪场管理" + ], + "summary": "获取单个猪舍", + "parameters": [ + { + "type": "integer", + "description": "猪舍ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "获取成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PigHouseResponse" + } + } + } + ] + } + } + } + }, + "put": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "更新一个已存在的猪舍信息", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "猪场管理" + ], + "summary": "更新猪舍", + "parameters": [ + { + "type": "integer", + "description": "猪舍ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "猪舍信息", + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.UpdatePigHouseRequest" + } + } + ], + "responses": { + "200": { + "description": "更新成功", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/controller.Response" + }, + { + "type": "object", + "properties": { + "data": { + "$ref": "#/definitions/dto.PigHouseResponse" + } + } + } + ] + } + } + } + }, + "delete": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据ID删除一个猪舍", + "produces": [ + "application/json" + ], + "tags": [ + "猪场管理" + ], + "summary": "删除猪舍", + "parameters": [ + { + "type": "integer", + "description": "猪舍ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "删除成功", + "schema": { + "$ref": "#/definitions/controller.Response" + } + } + } + } + }, "/api/v1/plans": { "get": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "获取所有计划的列表", "produces": [ "application/json" @@ -626,7 +3472,10 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/plan.ListPlansResponse" + "type": "array", + "items": { + "$ref": "#/definitions/dto.PlanResponse" + } } } } @@ -636,6 +3485,11 @@ } }, "post": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "创建一个新的计划,包括其基本信息和所有关联的子计划/任务。", "consumes": [ "application/json" @@ -654,7 +3508,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/plan.CreatePlanRequest" + "$ref": "#/definitions/dto.CreatePlanRequest" } } ], @@ -670,7 +3524,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/plan.PlanResponse" + "$ref": "#/definitions/dto.PlanResponse" } } } @@ -682,6 +3536,11 @@ }, "/api/v1/plans/{id}": { "get": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "根据计划ID获取单个计划的详细信息。", "produces": [ "application/json" @@ -711,7 +3570,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/plan.PlanResponse" + "$ref": "#/definitions/dto.PlanResponse" } } } @@ -721,6 +3580,11 @@ } }, "put": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "根据计划ID更新计划的详细信息。", "consumes": [ "application/json" @@ -746,7 +3610,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/plan.UpdatePlanRequest" + "$ref": "#/definitions/dto.UpdatePlanRequest" } } ], @@ -762,7 +3626,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/plan.PlanResponse" + "$ref": "#/definitions/dto.PlanResponse" } } } @@ -772,6 +3636,11 @@ } }, "delete": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "根据计划ID删除计划。(软删除)", "produces": [ "application/json" @@ -801,6 +3670,11 @@ }, "/api/v1/plans/{id}/start": { "post": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "根据计划ID启动一个计划的执行。", "produces": [ "application/json" @@ -830,6 +3704,11 @@ }, "/api/v1/plans/{id}/stop": { "post": { + "security": [ + { + "BearerAuth": [] + } + ], "description": "根据计划ID停止一个正在执行的计划。", "produces": [ "application/json" @@ -877,7 +3756,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/user.CreateUserRequest" + "$ref": "#/definitions/dto.CreateUserRequest" } } ], @@ -893,7 +3772,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/user.CreateUserResponse" + "$ref": "#/definitions/dto.CreateUserResponse" } } } @@ -923,7 +3802,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/user.LoginRequest" + "$ref": "#/definitions/dto.LoginRequest" } } ], @@ -939,7 +3818,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/user.LoginResponse" + "$ref": "#/definitions/dto.LoginResponse" } } } @@ -951,7 +3830,12 @@ }, "/api/v1/users/{id}/history": { "get": { - "description": "根据用户ID,分页获取该用户的操作审计日志。", + "security": [ + { + "BearerAuth": [] + } + ], + "description": "根据用户ID,分页获取该用户的操作审计日志。支持与通用日志查询接口相同的过滤和排序参数。", "produces": [ "application/json" ], @@ -967,24 +3851,49 @@ "in": "path", "required": true }, + { + "type": "string", + "name": "action_type", + "in": "query" + }, + { + "type": "string", + "name": "end_time", + "in": "query" + }, + { + "type": "string", + "name": "order_by", + "in": "query" + }, { "type": "integer", - "default": 1, - "description": "页码", "name": "page", "in": "query" }, { "type": "integer", - "default": 10, - "description": "每页大小", - "name": "page_size", + "name": "pageSize", "in": "query" }, { "type": "string", - "description": "按操作类型过滤", - "name": "action_type", + "name": "start_time", + "in": "query" + }, + { + "type": "string", + "name": "status", + "in": "query" + }, + { + "type": "integer", + "name": "user_id", + "in": "query" + }, + { + "type": "string", + "name": "username", "in": "query" } ], @@ -1000,7 +3909,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/definitions/user.ListHistoryResponse" + "$ref": "#/definitions/dto.ListUserActionLogResponse" } } } @@ -1075,7 +3984,7 @@ "CodeServiceUnavailable" ] }, - "device.AreaControllerResponse": { + "dto.AreaControllerResponse": { "type": "object", "properties": { "created_at": { @@ -1105,7 +4014,54 @@ } } }, - "device.CreateAreaControllerRequest": { + "dto.AssignEmptyPensToBatchRequest": { + "type": "object" + }, + "dto.BuyPigsRequest": { + "type": "object", + "required": [ + "penID", + "quantity", + "totalPrice", + "tradeDate", + "traderName", + "unitPrice" + ], + "properties": { + "penID": { + "description": "猪栏ID", + "type": "integer" + }, + "quantity": { + "description": "买入猪只数量", + "type": "integer", + "minimum": 1 + }, + "remarks": { + "description": "备注", + "type": "string" + }, + "totalPrice": { + "description": "总价", + "type": "number", + "minimum": 0 + }, + "tradeDate": { + "description": "交易日期", + "type": "string" + }, + "traderName": { + "description": "交易方名称", + "type": "string" + }, + "unitPrice": { + "description": "单价", + "type": "number", + "minimum": 0 + } + } + }, + "dto.CreateAreaControllerRequest": { "type": "object", "required": [ "name", @@ -1127,7 +4083,7 @@ } } }, - "device.CreateDeviceRequest": { + "dto.CreateDeviceRequest": { "type": "object", "required": [ "area_controller_id", @@ -1153,7 +4109,7 @@ } } }, - "device.CreateDeviceTemplateRequest": { + "dto.CreateDeviceTemplateRequest": { "type": "object", "required": [ "category", @@ -1185,123 +4141,135 @@ } } }, - "device.DeviceTemplateResponse": { + "dto.CreatePenRequest": { "type": "object", + "required": [ + "capacity", + "house_id", + "pen_number" + ], "properties": { - "category": { - "$ref": "#/definitions/models.DeviceCategory" + "capacity": { + "type": "integer" }, - "commands": { - "type": "object", - "additionalProperties": true + "house_id": { + "type": "integer" }, - "created_at": { + "pen_number": { "type": "string" - }, + } + } + }, + "dto.CreatePigHouseRequest": { + "type": "object", + "required": [ + "name" + ], + "properties": { "description": { "type": "string" }, + "name": { + "type": "string" + } + } + }, + "dto.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/dto.TaskRequest" + } + } + } + }, + "dto.CreateUserRequest": { + "type": "object", + "required": [ + "password", + "username" + ], + "properties": { + "password": { + "type": "string", + "example": "password123" + }, + "username": { + "type": "string", + "example": "newuser" + } + } + }, + "dto.CreateUserResponse": { + "type": "object", + "properties": { "id": { + "type": "integer", + "example": 1 + }, + "username": { + "type": "string", + "example": "newuser" + } + } + }, + "dto.DeviceCommandLogDTO": { + "type": "object", + "properties": { + "acknowledged_at": { + "type": "string" + }, + "device_id": { "type": "integer" }, - "manufacturer": { + "message_id": { "type": "string" }, - "name": { - "type": "string" + "received_success": { + "type": "boolean" }, - "updated_at": { + "sent_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": { + "dto.DeviceResponse": { "type": "object", "properties": { "area_controller_id": { @@ -1337,214 +4305,880 @@ } } }, - "models.DeviceCategory": { - "type": "string", - "enum": [ - "actuator", - "sensor" - ], - "x-enum-varnames": [ - "CategoryActuator", - "CategorySensor" - ] - }, - "models.PlanContentType": { - "type": "string", - "enum": [ - "sub_plans", - "tasks" - ], - "x-enum-comments": { - "PlanContentTypeSubPlans": "计划包含子计划", - "PlanContentTypeTasks": "计划包含任务" - }, - "x-enum-descriptions": [ - "计划包含子计划", - "计划包含任务" - ], - "x-enum-varnames": [ - "PlanContentTypeSubPlans", - "PlanContentTypeTasks" - ] - }, - "models.PlanExecutionType": { - "type": "string", - "enum": [ - "automatic", - "manual" - ], - "x-enum-comments": { - "PlanExecutionTypeAutomatic": "自动执行 (包含定时和循环)", - "PlanExecutionTypeManual": "手动执行" - }, - "x-enum-descriptions": [ - "自动执行 (包含定时和循环)", - "手动执行" - ], - "x-enum-varnames": [ - "PlanExecutionTypeAutomatic", - "PlanExecutionTypeManual" - ] - }, - "models.PlanStatus": { - "type": "integer", - "format": "int32", - "enum": [ - 0, - 1, - 2, - 3 - ], - "x-enum-comments": { - "PlanStatusDisabled": "禁用计划", - "PlanStatusEnabled": "启用计划", - "PlanStatusFailed": "执行失败", - "PlanStatusStopeed": "执行完毕" - }, - "x-enum-descriptions": [ - "禁用计划", - "启用计划", - "执行完毕", - "执行失败" - ], - "x-enum-varnames": [ - "PlanStatusDisabled", - "PlanStatusEnabled", - "PlanStatusStopeed", - "PlanStatusFailed" - ] - }, - "models.SensorType": { - "type": "string", - "enum": [ - "signal_metrics", - "battery_level", - "temperature", - "humidity", - "weight" - ], - "x-enum-comments": { - "SensorTypeBatteryLevel": "电池电量", - "SensorTypeHumidity": "湿度", - "SensorTypeSignalMetrics": "信号强度", - "SensorTypeTemperature": "温度", - "SensorTypeWeight": "重量" - }, - "x-enum-descriptions": [ - "信号强度", - "电池电量", - "温度", - "湿度", - "重量" - ], - "x-enum-varnames": [ - "SensorTypeSignalMetrics", - "SensorTypeBatteryLevel", - "SensorTypeTemperature", - "SensorTypeHumidity", - "SensorTypeWeight" - ] - }, - "models.TaskType": { - "type": "string", - "enum": [ - "plan_analysis", - "waiting", - "release_feed_weight" - ], - "x-enum-comments": { - "TaskPlanAnalysis": "解析Plan的Task列表并添加到待执行队列的特殊任务", - "TaskTypeReleaseFeedWeight": "下料口释放指定重量任务", - "TaskTypeWaiting": "等待任务" - }, - "x-enum-descriptions": [ - "解析Plan的Task列表并添加到待执行队列的特殊任务", - "等待任务", - "下料口释放指定重量任务" - ], - "x-enum-varnames": [ - "TaskPlanAnalysis", - "TaskTypeWaiting", - "TaskTypeReleaseFeedWeight" - ] - }, - "models.ValueDescriptor": { + "dto.DeviceTemplateResponse": { "type": "object", "properties": { - "multiplier": { - "description": "乘数,用于原始数据转换", - "type": "number" + "category": { + "$ref": "#/definitions/models.DeviceCategory" }, - "offset": { - "description": "偏移量,用于原始数据转换", - "type": "number" + "commands": { + "type": "object", + "additionalProperties": true }, - "type": { - "$ref": "#/definitions/models.SensorType" + "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" + } } } }, - "plan.CreatePlanRequest": { + "dto.FeedFormulaDTO": { "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": "automatic" + "id": { + "type": "integer" }, "name": { - "type": "string", - "example": "猪舍温度控制计划" + "type": "string" + } + } + }, + "dto.FeedUsageRecordDTO": { + "type": "object", + "properties": { + "amount": { + "type": "number" }, - "sub_plan_ids": { + "feed_formula": { + "$ref": "#/definitions/dto.FeedFormulaDTO" + }, + "feed_formula_id": { + "type": "integer" + }, + "id": { + "type": "integer" + }, + "operator_id": { + "type": "integer" + }, + "pen": { + "$ref": "#/definitions/dto.PenDTO" + }, + "pen_id": { + "type": "integer" + }, + "recorded_at": { + "type": "string" + }, + "remarks": { + "type": "string" + } + } + }, + "dto.ListDeviceCommandLogResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.DeviceCommandLogDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, + "dto.ListFeedUsageRecordResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.FeedUsageRecordDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, + "dto.ListMedicationLogResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.MedicationLogDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, + "dto.ListPendingCollectionResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.PendingCollectionDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, + "dto.ListPigBatchLogResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.PigBatchLogDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, + "dto.ListPigPurchaseResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.PigPurchaseDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, + "dto.ListPigSaleResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.PigSaleDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, + "dto.ListPigSickLogResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.PigSickLogDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, + "dto.ListPigTransferLogResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.PigTransferLogDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, + "dto.ListPlanExecutionLogResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.PlanExecutionLogDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, + "dto.ListRawMaterialPurchaseResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.RawMaterialPurchaseDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, + "dto.ListRawMaterialStockLogResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.RawMaterialStockLogDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, + "dto.ListSensorDataResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.SensorDataDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, + "dto.ListTaskExecutionLogResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.TaskExecutionLogDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, + "dto.ListUserActionLogResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.UserActionLogDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, + "dto.ListWeighingBatchResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.WeighingBatchDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, + "dto.ListWeighingRecordResponse": { + "type": "object", + "properties": { + "list": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.WeighingRecordDTO" + } + }, + "pagination": { + "$ref": "#/definitions/dto.PaginationDTO" + } + } + }, + "dto.LoginRequest": { + "type": "object", + "required": [ + "identifier", + "password" + ], + "properties": { + "identifier": { + "description": "Identifier 可以是用户名、邮箱、手机号、微信号或飞书账号", + "type": "string", + "example": "testuser" + }, + "password": { + "type": "string", + "example": "password123" + } + } + }, + "dto.LoginResponse": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "example": 1 + }, + "token": { + "type": "string", + "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." + }, + "username": { + "type": "string", + "example": "testuser" + } + } + }, + "dto.ManualControlDeviceRequest": { + "type": "object", + "properties": { + "action": { + "description": "Action 不传表示这是一个传感器, 会触发一次采集", + "type": "string" + } + } + }, + "dto.MedicationDTO": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + } + }, + "dto.MedicationLogDTO": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "dosage_used": { + "type": "number" + }, + "happened_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "medication": { + "$ref": "#/definitions/dto.MedicationDTO" + }, + "medication_id": { + "type": "integer" + }, + "operator_id": { + "type": "integer" + }, + "pig_batch_id": { + "type": "integer" + }, + "reason": { + "$ref": "#/definitions/models.MedicationReasonType" + }, + "target_count": { + "type": "integer" + } + } + }, + "dto.MovePigsIntoPenRequest": { + "type": "object", + "required": [ + "quantity", + "toPenID" + ], + "properties": { + "quantity": { + "description": "移入猪只数量", + "type": "integer", + "minimum": 1 + }, + "remarks": { + "description": "备注", + "type": "string" + }, + "toPenID": { + "description": "目标猪栏ID", + "type": "integer" + } + } + }, + "dto.PaginationDTO": { + "type": "object", + "properties": { + "page": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + }, + "total": { + "type": "integer" + } + } + }, + "dto.PenDTO": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + } + }, + "dto.PenResponse": { + "type": "object", + "properties": { + "capacity": { + "type": "integer" + }, + "house_id": { + "type": "integer" + }, + "id": { + "type": "integer" + }, + "pen_number": { + "type": "string" + }, + "pig_batch_id": { + "type": "integer" + }, + "status": { + "$ref": "#/definitions/models.PenStatus" + } + } + }, + "dto.PendingCollectionDTO": { + "type": "object", + "properties": { + "command_metadata": { "type": "array", "items": { "type": "integer" } }, - "tasks": { - "type": "array", - "items": { - "$ref": "#/definitions/plan.TaskRequest" - } + "correlation_id": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "device_id": { + "type": "integer" + }, + "fulfilled_at": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/models.PendingCollectionStatus" } } }, - "plan.ListPlansResponse": { + "dto.PigBatchCreateDTO": { + "type": "object", + "required": [ + "batch_number", + "initial_count", + "origin_type", + "start_date", + "status" + ], + "properties": { + "batch_number": { + "description": "批次编号,必填", + "type": "string" + }, + "initial_count": { + "description": "初始数量,必填,最小为1", + "type": "integer", + "minimum": 1 + }, + "origin_type": { + "description": "批次来源,必填", + "allOf": [ + { + "$ref": "#/definitions/models.PigBatchOriginType" + } + ] + }, + "start_date": { + "description": "批次开始日期,必填", + "type": "string" + }, + "status": { + "description": "批次状态,必填", + "allOf": [ + { + "$ref": "#/definitions/models.PigBatchStatus" + } + ] + } + } + }, + "dto.PigBatchLogDTO": { "type": "object", "properties": { - "plans": { - "type": "array", - "items": { - "$ref": "#/definitions/plan.PlanResponse" - } + "after_count": { + "type": "integer" }, - "total": { - "type": "integer", - "example": 100 + "before_count": { + "type": "integer" + }, + "change_count": { + "type": "integer" + }, + "change_type": { + "$ref": "#/definitions/models.LogChangeType" + }, + "created_at": { + "type": "string" + }, + "happened_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "operator_id": { + "type": "integer" + }, + "pig_batch_id": { + "type": "integer" + }, + "reason": { + "type": "string" + }, + "updated_at": { + "type": "string" } } }, - "plan.PlanResponse": { + "dto.PigBatchResponseDTO": { + "type": "object", + "properties": { + "batch_number": { + "description": "批次编号", + "type": "string" + }, + "create_time": { + "description": "创建时间", + "type": "string" + }, + "end_date": { + "description": "批次结束日期", + "type": "string" + }, + "id": { + "description": "批次ID", + "type": "integer" + }, + "initial_count": { + "description": "初始数量", + "type": "integer" + }, + "is_active": { + "description": "是否活跃", + "type": "boolean" + }, + "origin_type": { + "description": "批次来源", + "allOf": [ + { + "$ref": "#/definitions/models.PigBatchOriginType" + } + ] + }, + "start_date": { + "description": "批次开始日期", + "type": "string" + }, + "status": { + "description": "批次状态", + "allOf": [ + { + "$ref": "#/definitions/models.PigBatchStatus" + } + ] + }, + "update_time": { + "description": "更新时间", + "type": "string" + } + } + }, + "dto.PigBatchUpdateDTO": { + "type": "object", + "properties": { + "batch_number": { + "description": "批次编号,可选", + "type": "string" + }, + "end_date": { + "description": "批次结束日期,可选", + "type": "string" + }, + "initial_count": { + "description": "初始数量,可选", + "type": "integer" + }, + "origin_type": { + "description": "批次来源,可选", + "allOf": [ + { + "$ref": "#/definitions/models.PigBatchOriginType" + } + ] + }, + "start_date": { + "description": "批次开始日期,可选", + "type": "string" + }, + "status": { + "description": "批次状态,可选", + "allOf": [ + { + "$ref": "#/definitions/models.PigBatchStatus" + } + ] + } + } + }, + "dto.PigHouseResponse": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + } + }, + "dto.PigPurchaseDTO": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "operator_id": { + "type": "integer" + }, + "pig_batch_id": { + "type": "integer" + }, + "purchase_date": { + "type": "string" + }, + "quantity": { + "type": "integer" + }, + "remarks": { + "type": "string" + }, + "supplier": { + "type": "string" + }, + "total_price": { + "type": "number" + }, + "unit_price": { + "type": "number" + }, + "updated_at": { + "type": "string" + } + } + }, + "dto.PigSaleDTO": { + "type": "object", + "properties": { + "buyer": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "operator_id": { + "type": "integer" + }, + "pig_batch_id": { + "type": "integer" + }, + "quantity": { + "type": "integer" + }, + "remarks": { + "type": "string" + }, + "sale_date": { + "type": "string" + }, + "total_price": { + "type": "number" + }, + "unit_price": { + "type": "number" + }, + "updated_at": { + "type": "string" + } + } + }, + "dto.PigSickLogDTO": { + "type": "object", + "properties": { + "after_count": { + "type": "integer" + }, + "before_count": { + "type": "integer" + }, + "change_count": { + "type": "integer" + }, + "created_at": { + "type": "string" + }, + "happened_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "operator_id": { + "type": "integer" + }, + "pen_id": { + "type": "integer" + }, + "pig_batch_id": { + "type": "integer" + }, + "reason": { + "$ref": "#/definitions/models.PigBatchSickPigReasonType" + }, + "remarks": { + "type": "string" + }, + "treatment_location": { + "$ref": "#/definitions/models.PigBatchSickPigTreatmentLocation" + }, + "updated_at": { + "type": "string" + } + } + }, + "dto.PigTransferLogDTO": { + "type": "object", + "properties": { + "correlation_id": { + "type": "string" + }, + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "operator_id": { + "type": "integer" + }, + "pen_id": { + "type": "integer" + }, + "pig_batch_id": { + "type": "integer" + }, + "quantity": { + "type": "integer" + }, + "remarks": { + "type": "string" + }, + "transfer_time": { + "type": "string" + }, + "type": { + "$ref": "#/definitions/models.PigTransferType" + }, + "updated_at": { + "type": "string" + } + } + }, + "dto.PlanExecutionLogDTO": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "ended_at": { + "type": "string" + }, + "error": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "plan_id": { + "type": "integer" + }, + "started_at": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/models.ExecutionStatus" + }, + "updated_at": { + "type": "string" + } + } + }, + "dto.PlanResponse": { "type": "object", "properties": { "content_type": { @@ -1553,7 +5187,7 @@ "$ref": "#/definitions/models.PlanContentType" } ], - "example": "tasks" + "example": "任务" }, "cron_expression": { "type": "string", @@ -1577,7 +5211,7 @@ "$ref": "#/definitions/models.PlanExecutionType" } ], - "example": "automatic" + "example": "自动" }, "id": { "type": "integer", @@ -1593,27 +5227,382 @@ "$ref": "#/definitions/models.PlanStatus" } ], - "example": 0 + "example": "已启用" }, "sub_plans": { "type": "array", "items": { - "$ref": "#/definitions/plan.SubPlanResponse" + "$ref": "#/definitions/dto.SubPlanResponse" } }, "tasks": { "type": "array", "items": { - "$ref": "#/definitions/plan.TaskResponse" + "$ref": "#/definitions/dto.TaskResponse" } } } }, - "plan.SubPlanResponse": { + "dto.RawMaterialDTO": { + "type": "object", + "properties": { + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + } + }, + "dto.RawMaterialPurchaseDTO": { + "type": "object", + "properties": { + "amount": { + "type": "number" + }, + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "purchase_date": { + "type": "string" + }, + "raw_material": { + "$ref": "#/definitions/dto.RawMaterialDTO" + }, + "raw_material_id": { + "type": "integer" + }, + "supplier": { + "type": "string" + }, + "total_price": { + "type": "number" + }, + "unit_price": { + "type": "number" + } + } + }, + "dto.RawMaterialStockLogDTO": { + "type": "object", + "properties": { + "change_amount": { + "type": "number" + }, + "happened_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "raw_material_id": { + "type": "integer" + }, + "remarks": { + "type": "string" + }, + "source_id": { + "type": "integer" + }, + "source_type": { + "$ref": "#/definitions/models.StockLogSourceType" + } + } + }, + "dto.ReclassifyPenToNewBatchRequest": { + "type": "object", + "required": [ + "penID", + "toBatchID" + ], + "properties": { + "penID": { + "description": "待划拨的猪栏ID", + "type": "integer" + }, + "remarks": { + "description": "备注", + "type": "string" + }, + "toBatchID": { + "description": "目标猪批次ID", + "type": "integer" + } + } + }, + "dto.RecordCullRequest": { + "type": "object", + "required": [ + "happenedAt", + "penID", + "quantity" + ], + "properties": { + "happenedAt": { + "description": "发生时间", + "type": "string" + }, + "penID": { + "description": "猪栏ID", + "type": "integer" + }, + "quantity": { + "description": "淘汰猪数量", + "type": "integer", + "minimum": 1 + }, + "remarks": { + "description": "备注", + "type": "string" + } + } + }, + "dto.RecordDeathRequest": { + "type": "object", + "required": [ + "happenedAt", + "penID", + "quantity" + ], + "properties": { + "happenedAt": { + "description": "发生时间", + "type": "string" + }, + "penID": { + "description": "猪栏ID", + "type": "integer" + }, + "quantity": { + "description": "死亡猪数量", + "type": "integer", + "minimum": 1 + }, + "remarks": { + "description": "备注", + "type": "string" + } + } + }, + "dto.RecordSickPigCullRequest": { + "type": "object", + "required": [ + "happenedAt", + "penID", + "quantity", + "treatmentLocation" + ], + "properties": { + "happenedAt": { + "description": "发生时间", + "type": "string" + }, + "penID": { + "description": "猪栏ID", + "type": "integer" + }, + "quantity": { + "description": "淘汰猪数量", + "type": "integer", + "minimum": 1 + }, + "remarks": { + "description": "备注", + "type": "string" + }, + "treatmentLocation": { + "description": "治疗地点", + "allOf": [ + { + "$ref": "#/definitions/models.PigBatchSickPigTreatmentLocation" + } + ] + } + } + }, + "dto.RecordSickPigDeathRequest": { + "type": "object", + "required": [ + "happenedAt", + "penID", + "quantity", + "treatmentLocation" + ], + "properties": { + "happenedAt": { + "description": "发生时间", + "type": "string" + }, + "penID": { + "description": "猪栏ID", + "type": "integer" + }, + "quantity": { + "description": "死亡猪数量", + "type": "integer", + "minimum": 1 + }, + "remarks": { + "description": "备注", + "type": "string" + }, + "treatmentLocation": { + "description": "治疗地点", + "allOf": [ + { + "$ref": "#/definitions/models.PigBatchSickPigTreatmentLocation" + } + ] + } + } + }, + "dto.RecordSickPigRecoveryRequest": { + "type": "object", + "required": [ + "happenedAt", + "penID", + "quantity", + "treatmentLocation" + ], + "properties": { + "happenedAt": { + "description": "发生时间", + "type": "string" + }, + "penID": { + "description": "猪栏ID", + "type": "integer" + }, + "quantity": { + "description": "康复猪数量", + "type": "integer", + "minimum": 1 + }, + "remarks": { + "description": "备注", + "type": "string" + }, + "treatmentLocation": { + "description": "治疗地点", + "allOf": [ + { + "$ref": "#/definitions/models.PigBatchSickPigTreatmentLocation" + } + ] + } + } + }, + "dto.RecordSickPigsRequest": { + "type": "object", + "required": [ + "happenedAt", + "penID", + "quantity", + "treatmentLocation" + ], + "properties": { + "happenedAt": { + "description": "发生时间", + "type": "string" + }, + "penID": { + "description": "猪栏ID", + "type": "integer" + }, + "quantity": { + "description": "病猪数量", + "type": "integer", + "minimum": 1 + }, + "remarks": { + "description": "备注", + "type": "string" + }, + "treatmentLocation": { + "description": "治疗地点", + "allOf": [ + { + "$ref": "#/definitions/models.PigBatchSickPigTreatmentLocation" + } + ] + } + } + }, + "dto.SellPigsRequest": { + "type": "object", + "required": [ + "penID", + "quantity", + "totalPrice", + "tradeDate", + "traderName", + "unitPrice" + ], + "properties": { + "penID": { + "description": "猪栏ID", + "type": "integer" + }, + "quantity": { + "description": "卖出猪只数量", + "type": "integer", + "minimum": 1 + }, + "remarks": { + "description": "备注", + "type": "string" + }, + "totalPrice": { + "description": "总价", + "type": "number", + "minimum": 0 + }, + "tradeDate": { + "description": "交易日期", + "type": "string" + }, + "traderName": { + "description": "交易方名称", + "type": "string" + }, + "unitPrice": { + "description": "单价", + "type": "number", + "minimum": 0 + } + } + }, + "dto.SensorDataDTO": { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "type": "integer" + } + }, + "device_id": { + "type": "integer" + }, + "regional_controller_id": { + "type": "integer" + }, + "sensor_type": { + "$ref": "#/definitions/models.SensorType" + }, + "time": { + "type": "string" + } + } + }, + "dto.SubPlanResponse": { "type": "object", "properties": { "child_plan": { - "$ref": "#/definitions/plan.PlanResponse" + "$ref": "#/definitions/dto.PlanResponse" }, "child_plan_id": { "type": "integer", @@ -1633,7 +5622,61 @@ } } }, - "plan.TaskRequest": { + "dto.TaskDTO": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "name": { + "type": "string" + } + } + }, + "dto.TaskExecutionLogDTO": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "ended_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "output": { + "type": "string" + }, + "plan_execution_log_id": { + "type": "integer" + }, + "started_at": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/models.ExecutionStatus" + }, + "task": { + "description": "嵌套的任务信息", + "allOf": [ + { + "$ref": "#/definitions/dto.TaskDTO" + } + ] + }, + "task_id": { + "type": "integer" + }, + "updated_at": { + "type": "string" + } + } + }, + "dto.TaskRequest": { "type": "object", "properties": { "description": { @@ -1658,11 +5701,11 @@ "$ref": "#/definitions/models.TaskType" } ], - "example": "waiting" + "example": "等待" } } }, - "plan.TaskResponse": { + "dto.TaskResponse": { "type": "object", "properties": { "description": { @@ -1695,12 +5738,228 @@ "$ref": "#/definitions/models.TaskType" } ], - "example": "waiting" + "example": "等待" } } }, - "plan.UpdatePlanRequest": { + "dto.TransferPigsAcrossBatchesRequest": { "type": "object", + "required": [ + "destBatchID", + "fromPenID", + "quantity", + "toPenID" + ], + "properties": { + "destBatchID": { + "description": "目标猪批次ID", + "type": "integer" + }, + "fromPenID": { + "description": "源猪栏ID", + "type": "integer" + }, + "quantity": { + "description": "调栏猪只数量", + "type": "integer", + "minimum": 1 + }, + "remarks": { + "description": "备注", + "type": "string" + }, + "toPenID": { + "description": "目标猪栏ID", + "type": "integer" + } + } + }, + "dto.TransferPigsWithinBatchRequest": { + "type": "object", + "required": [ + "fromPenID", + "quantity", + "toPenID" + ], + "properties": { + "fromPenID": { + "description": "源猪栏ID", + "type": "integer" + }, + "quantity": { + "description": "调栏猪只数量", + "type": "integer", + "minimum": 1 + }, + "remarks": { + "description": "备注", + "type": "string" + }, + "toPenID": { + "description": "目标猪栏ID", + "type": "integer" + } + } + }, + "dto.UpdateAreaControllerRequest": { + "type": "object", + "required": [ + "name", + "network_id" + ], + "properties": { + "location": { + "type": "string" + }, + "name": { + "type": "string" + }, + "network_id": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": true + } + } + }, + "dto.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 + } + } + }, + "dto.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" + } + } + } + }, + "dto.UpdatePenRequest": { + "type": "object", + "required": [ + "capacity", + "house_id", + "pen_number", + "status" + ], + "properties": { + "capacity": { + "type": "integer" + }, + "house_id": { + "type": "integer" + }, + "pen_number": { + "type": "string" + }, + "status": { + "description": "添加oneof校验", + "enum": [ + "空闲", + "使用中", + "病猪栏", + "康复栏", + "清洗消毒", + "维修中" + ], + "allOf": [ + { + "$ref": "#/definitions/models.PenStatus" + } + ] + } + } + }, + "dto.UpdatePenStatusRequest": { + "type": "object", + "required": [ + "status" + ], + "properties": { + "status": { + "enum": [ + "空闲", + "使用中", + "病猪栏", + "康复栏", + "清洗消毒", + "维修中" + ], + "allOf": [ + { + "$ref": "#/definitions/models.PenStatus" + } + ], + "example": "病猪栏" + } + } + }, + "dto.UpdatePigHouseRequest": { + "type": "object", + "required": [ + "name" + ], + "properties": { + "description": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "dto.UpdatePlanRequest": { + "type": "object", + "required": [ + "execution_type" + ], "properties": { "cron_expression": { "type": "string", @@ -1720,7 +5979,7 @@ "$ref": "#/definitions/models.PlanExecutionType" } ], - "example": "automatic" + "example": "自动" }, "name": { "type": "string", @@ -1735,115 +5994,533 @@ "tasks": { "type": "array", "items": { - "$ref": "#/definitions/plan.TaskRequest" + "$ref": "#/definitions/dto.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": { + "dto.UserActionLogDTO": { "type": "object", "properties": { "action_type": { - "type": "string", - "example": "更新设备" + "type": "string" }, "description": { - "type": "string", - "example": "设备更新成功" + "type": "string" + }, + "http_method": { + "type": "string" + }, + "http_path": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "result_details": { + "type": "string" + }, + "source_ip": { + "type": "string" + }, + "status": { + "$ref": "#/definitions/models.AuditStatus" + }, + "target_resource": { + "type": "array", + "items": { + "type": "integer" + } }, - "target_resource": {}, "time": { "type": "string" }, "user_id": { - "type": "integer", - "example": 101 + "type": "integer" }, "username": { - "type": "string", - "example": "testuser" + "type": "string" } } }, - "user.ListHistoryResponse": { + "dto.WeighingBatchDTO": { "type": "object", "properties": { - "history": { - "type": "array", - "items": { - "$ref": "#/definitions/user.HistoryResponse" - } + "created_at": { + "type": "string" }, - "total": { - "type": "integer", - "example": 100 - } - } - }, - "user.LoginRequest": { - "type": "object", - "required": [ - "identifier", - "password" - ], - "properties": { - "identifier": { - "description": "Identifier 可以是用户名、邮箱、手机号、微信号或飞书账号", - "type": "string", - "example": "testuser" + "description": { + "type": "string" }, - "password": { - "type": "string", - "example": "password123" - } - } - }, - "user.LoginResponse": { - "type": "object", - "properties": { "id": { - "type": "integer", - "example": 1 + "type": "integer" }, - "token": { - "type": "string", - "example": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." + "pig_batch_id": { + "type": "integer" }, - "username": { - "type": "string", - "example": "testuser" + "updated_at": { + "type": "string" + }, + "weighing_time": { + "type": "string" + } + } + }, + "dto.WeighingRecordDTO": { + "type": "object", + "properties": { + "created_at": { + "type": "string" + }, + "id": { + "type": "integer" + }, + "operator_id": { + "type": "integer" + }, + "pen_id": { + "type": "integer" + }, + "remark": { + "type": "string" + }, + "updated_at": { + "type": "string" + }, + "weighing_batch_id": { + "type": "integer" + }, + "weighing_time": { + "type": "string" + }, + "weight": { + "type": "number" + } + } + }, + "models.AuditStatus": { + "type": "string", + "enum": [ + "成功", + "失败" + ], + "x-enum-varnames": [ + "AuditStatusSuccess", + "AuditStatusFailed" + ] + }, + "models.DeviceCategory": { + "type": "string", + "enum": [ + "执行器", + "传感器" + ], + "x-enum-varnames": [ + "CategoryActuator", + "CategorySensor" + ] + }, + "models.ExecutionStatus": { + "type": "string", + "enum": [ + "已开始", + "已完成", + "失败", + "已取消", + "等待中" + ], + "x-enum-comments": { + "ExecutionStatusCancelled": "执行取消", + "ExecutionStatusCompleted": "执行完成", + "ExecutionStatusFailed": "执行失败", + "ExecutionStatusStarted": "开始执行", + "ExecutionStatusWaiting": "等待执行 (用于预写日志)" + }, + "x-enum-descriptions": [ + "开始执行", + "执行完成", + "执行失败", + "执行取消", + "等待执行 (用于预写日志)" + ], + "x-enum-varnames": [ + "ExecutionStatusStarted", + "ExecutionStatusCompleted", + "ExecutionStatusFailed", + "ExecutionStatusCancelled", + "ExecutionStatusWaiting" + ] + }, + "models.LogChangeType": { + "type": "string", + "enum": [ + "死亡", + "淘汰", + "销售", + "购买", + "转入", + "转出", + "盘点校正" + ], + "x-enum-varnames": [ + "ChangeTypeDeath", + "ChangeTypeCull", + "ChangeTypeSale", + "ChangeTypeBuy", + "ChangeTypeTransferIn", + "ChangeTypeTransferOut", + "ChangeTypeCorrection" + ] + }, + "models.MedicationReasonType": { + "type": "string", + "enum": [ + "预防", + "治疗", + "保健" + ], + "x-enum-varnames": [ + "ReasonTypePreventive", + "ReasonTypeTreatment", + "ReasonTypeHealthCare" + ] + }, + "models.PenStatus": { + "type": "string", + "enum": [ + "空闲", + "使用中", + "病猪栏", + "康复栏", + "清洗消毒", + "维修中" + ], + "x-enum-varnames": [ + "PenStatusEmpty", + "PenStatusOccupied", + "PenStatusSickPen", + "PenStatusRecovering", + "PenStatusCleaning", + "PenStatusUnderMaint" + ] + }, + "models.PendingCollectionStatus": { + "type": "string", + "enum": [ + "等待中", + "已完成", + "已超时" + ], + "x-enum-comments": { + "PendingStatusFulfilled": "已收到设备响应并成功处理", + "PendingStatusPending": "请求已发送,等待设备响应", + "PendingStatusTimedOut": "请求超时,未收到设备响应" + }, + "x-enum-descriptions": [ + "请求已发送,等待设备响应", + "已收到设备响应并成功处理", + "请求超时,未收到设备响应" + ], + "x-enum-varnames": [ + "PendingStatusPending", + "PendingStatusFulfilled", + "PendingStatusTimedOut" + ] + }, + "models.PigBatchOriginType": { + "type": "string", + "enum": [ + "自繁", + "外购" + ], + "x-enum-varnames": [ + "OriginTypeSelfFarrowed", + "OriginTypePurchased" + ] + }, + "models.PigBatchSickPigReasonType": { + "type": "string", + "enum": [ + "患病", + "康复", + "死亡", + "淘汰", + "转入", + "转出", + "其他" + ], + "x-enum-comments": { + "SickPigReasonTypeDeath": "猪只死亡", + "SickPigReasonTypeEliminate": "猪只淘汰", + "SickPigReasonTypeIllness": "猪只患病", + "SickPigReasonTypeOther": "其他原因", + "SickPigReasonTypeRecovery": "猪只康复", + "SickPigReasonTypeTransferIn": "病猪转入当前批次", + "SickPigReasonTypeTransferOut": "病猪转出当前批次 (例如转到其他批次或出售)" + }, + "x-enum-descriptions": [ + "猪只患病", + "猪只康复", + "猪只死亡", + "猪只淘汰", + "病猪转入当前批次", + "病猪转出当前批次 (例如转到其他批次或出售)", + "其他原因" + ], + "x-enum-varnames": [ + "SickPigReasonTypeIllness", + "SickPigReasonTypeRecovery", + "SickPigReasonTypeDeath", + "SickPigReasonTypeEliminate", + "SickPigReasonTypeTransferIn", + "SickPigReasonTypeTransferOut", + "SickPigReasonTypeOther" + ] + }, + "models.PigBatchSickPigTreatmentLocation": { + "type": "string", + "enum": [ + "原地治疗", + "病猪栏治疗" + ], + "x-enum-varnames": [ + "TreatmentLocationOnSite", + "TreatmentLocationSickBay" + ] + }, + "models.PigBatchStatus": { + "type": "string", + "enum": [ + "保育", + "生长", + "育肥", + "待售", + "已出售", + "已归档" + ], + "x-enum-comments": { + "BatchStatusArchived": "批次结束(如全群淘汰等)", + "BatchStatusFinishing": "最后的育肥阶段", + "BatchStatusForSale": "达到出栏标准", + "BatchStatusGrowing": "生长育肥阶段", + "BatchStatusWeaning": "从断奶到保育结束" + }, + "x-enum-descriptions": [ + "从断奶到保育结束", + "生长育肥阶段", + "最后的育肥阶段", + "达到出栏标准", + "", + "批次结束(如全群淘汰等)" + ], + "x-enum-varnames": [ + "BatchStatusWeaning", + "BatchStatusGrowing", + "BatchStatusFinishing", + "BatchStatusForSale", + "BatchStatusSold", + "BatchStatusArchived" + ] + }, + "models.PigTransferType": { + "type": "string", + "enum": [ + "群内调栏", + "跨群调栏", + "销售", + "死亡", + "淘汰", + "新购入", + "产房转入" + ], + "x-enum-comments": { + "PigTransferTypeCrossBatch": "不同猪群间的调动", + "PigTransferTypeCull": "猪只淘汰", + "PigTransferTypeDeath": "猪只死亡", + "PigTransferTypeDeliveryRoomTransfor": "产房转入", + "PigTransferTypeInternal": "同一猪群内猪栏间的调动", + "PigTransferTypePurchase": "新购入猪只", + "PigTransferTypeSale": "猪只售出" + }, + "x-enum-descriptions": [ + "同一猪群内猪栏间的调动", + "不同猪群间的调动", + "猪只售出", + "猪只死亡", + "猪只淘汰", + "新购入猪只", + "产房转入" + ], + "x-enum-varnames": [ + "PigTransferTypeInternal", + "PigTransferTypeCrossBatch", + "PigTransferTypeSale", + "PigTransferTypeDeath", + "PigTransferTypeCull", + "PigTransferTypePurchase", + "PigTransferTypeDeliveryRoomTransfor" + ] + }, + "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.StockLogSourceType": { + "type": "string", + "enum": [ + "采购入库", + "饲喂出库", + "变质出库", + "售卖出库", + "杂用领取", + "手动盘点" + ], + "x-enum-varnames": [ + "StockLogSourcePurchase", + "StockLogSourceFeeding", + "StockLogSourceDeteriorate", + "StockLogSourceSale", + "StockLogSourceMiscellaneous", + "StockLogSourceManual" + ] + }, + "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" } } } + }, + "securityDefinitions": { + "BearerAuth": { + "type": "apiKey", + "name": "Authorization", + "in": "header" + } } -} \ No newline at end of file +} diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index bf3b2fc5..bbfa190d 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -9676,6 +9676,20 @@ "node": ">= 0.6" } }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmmirror.com/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "optional": true, + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/undici-types": { "version": "7.12.0", "resolved": "https://registry.npmmirror.com/undici-types/-/undici-types-7.12.0.tgz", diff --git a/package-lock.json b/package-lock.json index a9f66caf..7c8dda84 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9718,6 +9718,20 @@ "node": ">= 0.6" } }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmmirror.com/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "optional": true, + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/undici-types": { "version": "7.12.0", "resolved": "https://registry.npmmirror.com/undici-types/-/undici-types-7.12.0.tgz", diff --git a/src/api/areaController.js b/src/api/areaController.js new file mode 100644 index 00000000..5cc2f3ca --- /dev/null +++ b/src/api/areaController.js @@ -0,0 +1,46 @@ +import http from '../utils/http'; + +/** + * 获取系统中所有区域主控的列表 + * @returns {Promise<*>} + */ +export const getAreaControllers = () => { + return http.get('/api/v1/area-controllers'); +}; + +/** + * 根据提供的信息创建一个新区域主控 + * @param {object} areaControllerData - 区域主控信息,对应 dto.CreateAreaControllerRequest + * @returns {Promise<*>} + */ +export const createAreaController = (areaControllerData) => { + return http.post('/api/v1/area-controllers', areaControllerData); +}; + +/** + * 根据ID获取单个区域主控的详细信息 + * @param {string} id - 区域主控ID + * @returns {Promise<*>} + */ +export const getAreaControllerById = (id) => { + return http.get(`/api/v1/area-controllers/${id}`); +}; + +/** + * 根据ID更新一个已存在的区域主控信息 + * @param {string} id - 区域主控ID + * @param {object} areaControllerData - 要更新的区域主控信息,对应 dto.UpdateAreaControllerRequest + * @returns {Promise<*>} + */ +export const updateAreaController = (id, areaControllerData) => { + return http.put(`/api/v1/area-controllers/${id}`, areaControllerData); +}; + +/** + * 根据ID删除一个区域主控(软删除) + * @param {string} id - 区域主控ID + * @returns {Promise<*>} + */ +export const deleteAreaController = (id) => { + return http.delete(`/api/v1/area-controllers/${id}`); +}; diff --git a/src/api/device.js b/src/api/device.js index c5eb8b9c..92635213 100644 --- a/src/api/device.js +++ b/src/api/device.js @@ -1,101 +1,56 @@ -import http from '../utils/http.js'; +import http from '../utils/http'; /** - * 区域主控管理API + * 获取系统中所有设备的列表 + * @returns {Promise<*>} */ -export class AreaControllerApi { - /** - * 获取区域主控列表 - * @returns {Promise} 区域主控列表 - */ - static list() { - return http.get('/api/v1/area-controllers'); - } - - /** - * 创建新区域主控 - * @param {Object} areaControllerData 区域主控数据 - * @returns {Promise} 创建结果 - */ - static create(areaControllerData) { - return http.post('/api/v1/area-controllers', areaControllerData); - } - - /** - * 获取区域主控详情 - * @param {string|number} id 区域主控ID - * @returns {Promise} 区域主控详情 - */ - static get(id) { - return http.get(`/api/v1/area-controllers/${id}`); - } - - /** - * 更新区域主控信息 - * @param {string|number} id 区域主控ID - * @param {Object} areaControllerData 区域主控数据 - * @returns {Promise} 更新结果 - */ - static update(id, areaControllerData) { - return http.put(`/api/v1/area-controllers/${id}`, areaControllerData); - } - - /** - * 删除区域主控 - * @param {string|number} id 区域主控ID - * @returns {Promise} 删除结果 - */ - static delete(id) { - return http.delete(`/api/v1/area-controllers/${id}`); - } -} +export const getDevices = () => { + return http.get('/api/v1/devices'); +}; /** - * 普通设备管理API + * 根据提供的信息创建一个新设备 + * @param {object} deviceData - 设备信息,对应 dto.CreateDeviceRequest + * @returns {Promise<*>} */ -export class DeviceApi { - /** - * 获取设备列表 - * @returns {Promise} 设备列表 - */ - static list() { - return http.get('/api/v1/devices'); - } +export const createDevice = (deviceData) => { + return http.post('/api/v1/devices', deviceData); +}; - /** - * 创建新设备 - * @param {Object} deviceData 设备数据 - * @returns {Promise} 创建结果 - */ - static create(deviceData) { - return http.post('/api/v1/devices', deviceData); - } +/** + * 根据设备ID获取单个设备的详细信息 + * @param {string} id - 设备ID + * @returns {Promise<*>} + */ +export const getDeviceById = (id) => { + return http.get(`/api/v1/devices/${id}`); +}; - /** - * 获取设备详情 - * @param {string|number} id 设备ID - * @returns {Promise} 设备详情 - */ - static get(id) { - return http.get(`/api/v1/devices/${id}`); - } +/** + * 根据设备ID更新一个已存在的设备信息 + * @param {string} id - 设备ID + * @param {object} deviceData - 要更新的设备信息,对应 dto.UpdateDeviceRequest + * @returns {Promise<*>} + */ +export const updateDevice = (id, deviceData) => { + return http.put(`/api/v1/devices/${id}`, deviceData); +}; - /** - * 更新设备信息 - * @param {string|number} id 设备ID - * @param {Object} deviceData 设备数据 - * @returns {Promise} 更新结果 - */ - static update(id, deviceData) { - return http.put(`/api/v1/devices/${id}`, deviceData); - } +/** + * 根据设备ID删除一个设备(软删除) + * @param {string} id - 设备ID + * @returns {Promise<*>} + */ +export const deleteDevice = (id) => { + return http.delete(`/api/v1/devices/${id}`); +}; - /** - * 删除设备 - * @param {string|number} id 设备ID - * @returns {Promise} 删除结果 - */ - static delete(id) { - return http.delete(`/api/v1/devices/${id}`); - } -} +/** + * 根据设备ID和指定的动作(开启或关闭)来手动控制设备 + * @param {string} id - 设备ID + * @param {object} manualControlData - 手动控制指令,对应 dto.ManualControlDeviceRequest + * @returns {Promise<*>} + */ +export const manualControlDevice = (id, manualControlData) => { + return http.post(`/api/v1/devices/manual-control/${id}`, manualControlData); +}; diff --git a/src/api/deviceTemplate.js b/src/api/deviceTemplate.js index 109a2708..f34e33ff 100644 --- a/src/api/deviceTemplate.js +++ b/src/api/deviceTemplate.js @@ -1,53 +1,46 @@ -import http from '../utils/http.js'; +import http from '../utils/http'; /** - * 设备模板管理API + * 获取系统中所有设备模板的列表 + * @returns {Promise<*>} */ -export class DeviceTemplateApi { - /** - * 获取设备模板列表 - * @returns {Promise} 设备模板列表 - */ - static list() { - return http.get('/api/v1/device-templates'); - } +export const getDeviceTemplates = () => { + return http.get('/api/v1/device-templates'); +}; - /** - * 创建新设备模板 - * @param {Object} deviceTemplateData 设备模板数据 - * @returns {Promise} 创建结果 - */ - static create(deviceTemplateData) { - return http.post('/api/v1/device-templates', deviceTemplateData); - } +/** + * 根据提供的信息创建一个新设备模板 + * @param {object} deviceTemplateData - 设备模板信息,对应 dto.CreateDeviceTemplateRequest + * @returns {Promise<*>} + */ +export const createDeviceTemplate = (deviceTemplateData) => { + return http.post('/api/v1/device-templates', deviceTemplateData); +}; - /** - * 获取设备模板详情 - * @param {string|number} id 设备模板ID - * @returns {Promise} 设备模板详情 - */ - static get(id) { - return http.get(`/api/v1/device-templates/${id}`); - } +/** + * 根据设备模板ID获取单个设备模板的详细信息 + * @param {string} id - 设备模板ID + * @returns {Promise<*>} + */ +export const getDeviceTemplateById = (id) => { + return http.get(`/api/v1/device-templates/${id}`); +}; - /** - * 更新设备模板信息 - * @param {string|number} id 设备模板ID - * @param {Object} deviceTemplateData 设备模板数据 - * @returns {Promise} 更新结果 - */ - static update(id, deviceTemplateData) { - return http.put(`/api/v1/device-templates/${id}`, deviceTemplateData); - } +/** + * 根据设备模板ID更新一个已存在的设备模板信息 + * @param {string} id - 设备模板ID + * @param {object} deviceTemplateData - 要更新的设备模板信息,对应 dto.UpdateDeviceTemplateRequest + * @returns {Promise<*>} + */ +export const updateDeviceTemplate = (id, deviceTemplateData) => { + return http.put(`/api/v1/device-templates/${id}`, deviceTemplateData); +}; - /** - * 删除设备模板 - * @param {string|number} id 设备模板ID - * @returns {Promise} 删除结果 - */ - static delete(id) { - return http.delete(`/api/v1/device-templates/${id}`); - } -} - -export default DeviceTemplateApi; \ No newline at end of file +/** + * 根据设备模板ID删除一个设备模板(软删除) + * @param {string} id - 设备模板ID + * @returns {Promise<*>} + */ +export const deleteDeviceTemplate = (id) => { + return http.delete(`/api/v1/device-templates/${id}`); +}; diff --git a/src/api/monitor.js b/src/api/monitor.js new file mode 100644 index 00000000..c1f29918 --- /dev/null +++ b/src/api/monitor.js @@ -0,0 +1,154 @@ +import http from '../utils/http'; + +/** + * 获取设备命令日志列表 + * @param {object} params - 查询参数 + * @returns {Promise<*>} + */ +export const getDeviceCommandLogs = (params) => { + return http.get('/api/v1/monitor/device-command-logs', { params }); +}; + +/** + * 获取饲料使用记录列表 + * @param {object} params - 查询参数 + * @returns {Promise<*>} + */ +export const getFeedUsageRecords = (params) => { + return http.get('/api/v1/monitor/feed-usage-records', { params }); +}; + +/** + * 获取用药记录列表 + * @param {object} params - 查询参数 + * @returns {Promise<*>} + */ +export const getMedicationLogs = (params) => { + return http.get('/api/v1/monitor/medication-logs', { params }); +}; + +/** + * 获取待采集请求列表 + * @param {object} params - 查询参数 + * @returns {Promise<*>} + */ +export const getPendingCollections = (params) => { + return http.get('/api/v1/monitor/pending-collections', { params }); +}; + +/** + * 获取猪批次日志列表 + * @param {object} params - 查询参数 + * @returns {Promise<*>} + */ +export const getPigBatchLogs = (params) => { + return http.get('/api/v1/monitor/pig-batch-logs', { params }); +}; + +/** + * 获取猪只采购记录列表 + * @param {object} params - 查询参数 + * @returns {Promise<*>} + */ +export const getPigPurchases = (params) => { + return http.get('/api/v1/monitor/pig-purchases', { params }); +}; + +/** + * 获取猪只售卖记录列表 + * @param {object} params - 查询参数 + * @returns {Promise<*>} + */ +export const getPigSales = (params) => { + return http.get('/api/v1/monitor/pig-sales', { params }); +}; + +/** + * 获取病猪日志列表 + * @param {object} params - 查询参数 + * @returns {Promise<*>} + */ +export const getPigSickLogs = (params) => { + return http.get('/api/v1/monitor/pig-sick-logs', { params }); +}; + +/** + * 获取猪只迁移日志列表 + * @param {object} params - 查询参数 + * @returns {Promise<*>} + */ +export const getPigTransferLogs = (params) => { + return http.get('/api/v1/monitor/pig-transfer-logs', { params }); +}; + +/** + * 获取计划执行日志列表 + * @param {object} params - 查询参数 + * @returns {Promise<*>} + */ +export const getPlanExecutionLogs = (params) => { + return http.get('/api/v1/monitor/plan-execution-logs', { params }); +}; + +/** + * 获取原料采购记录列表 + * @param {object} params - 查询参数 + * @returns {Promise<*>} + */ +export const getRawMaterialPurchases = (params) => { + return http.get('/api/v1/monitor/raw-material-purchases', { params }); +}; + +/** + * 获取原料库存日志列表 + * @param {object} params - 查询参数 + * @returns {Promise<*>} + */ +export const getRawMaterialStockLogs = (params) => { + return http.get('/api/v1/monitor/raw-material-stock-logs', { params }); +}; + +/** + * 获取传感器数据列表 + * @param {object} params - 查询参数 + * @returns {Promise<*>} + */ +export const getSensorData = (params) => { + return http.get('/api/v1/monitor/sensor-data', { params }); +}; + +/** + * 获取任务执行日志列表 + * @param {object} params - 查询参数 + * @returns {Promise<*>} + */ +export const getTaskExecutionLogs = (params) => { + return http.get('/api/v1/monitor/task-execution-logs', { params }); +}; + +/** + * 获取用户操作日志列表 + * @param {object} params - 查询参数 + * @returns {Promise<*>} + */ +export const getUserActionLogs = (params) => { + return http.get('/api/v1/monitor/user-action-logs', { params }); +}; + +/** + * 获取批次称重记录列表 + * @param {object} params - 查询参数 + * @returns {Promise<*>} + */ +export const getWeighingBatches = (params) => { + return http.get('/api/v1/monitor/weighing-batches', { params }); +}; + +/** + * 获取单次称重记录列表 + * @param {object} params - 查询参数 + * @returns {Promise<*>} + */ +export const getWeighingRecords = (params) => { + return http.get('/api/v1/monitor/weighing-records', { params }); +}; diff --git a/src/api/pen.js b/src/api/pen.js new file mode 100644 index 00000000..e446b8c8 --- /dev/null +++ b/src/api/pen.js @@ -0,0 +1,56 @@ +import http from '../utils/http'; + +/** + * 获取所有猪栏的列表 + * @returns {Promise<*>} + */ +export const getPens = () => { + return http.get('/api/v1/pens'); +}; + +/** + * 创建一个新的猪栏 + * @param {object} penData - 猪栏信息,对应 dto.CreatePenRequest + * @returns {Promise<*>} + */ +export const createPen = (penData) => { + return http.post('/api/v1/pens', penData); +}; + +/** + * 根据ID获取单个猪栏信息 + * @param {number} id - 猪栏ID + * @returns {Promise<*>} + */ +export const getPenById = (id) => { + return http.get(`/api/v1/pens/${id}`); +}; + +/** + * 更新一个已存在的猪栏信息 + * @param {number} id - 猪栏ID + * @param {object} penData - 猪栏信息,对应 dto.UpdatePenRequest + * @returns {Promise<*>} + */ +export const updatePen = (id, penData) => { + return http.put(`/api/v1/pens/${id}`, penData); +}; + +/** + * 根据ID删除一个猪栏 + * @param {number} id - 猪栏ID + * @returns {Promise<*>} + */ +export const deletePen = (id) => { + return http.delete(`/api/v1/pens/${id}`); +}; + +/** + * 更新指定猪栏的当前状态 + * @param {number} id - 猪栏ID + * @param {object} statusData - 新的猪栏状态,对应 dto.UpdatePenStatusRequest + * @returns {Promise<*>} + */ +export const updatePenStatus = (id, statusData) => { + return http.put(`/api/v1/pens/${id}/status`, statusData); +}; diff --git a/src/api/pigBatch.js b/src/api/pigBatch.js new file mode 100644 index 00000000..0c7a5dc4 --- /dev/null +++ b/src/api/pigBatch.js @@ -0,0 +1,193 @@ +import http from '../utils/http'; + +// --- 猪批次基础操作 --- + +/** + * 获取所有猪批次的列表 + * @param {object} params - 查询参数,例如 { is_active: true } + * @returns {Promise<*>} + */ +export const getPigBatches = (params) => { + return http.get('/api/v1/pig-batches', { params }); +}; + +/** + * 创建一个新的猪批次 + * @param {object} batchData - 猪批次信息,对应 dto.PigBatchCreateDTO + * @returns {Promise<*>} + */ +export const createPigBatch = (batchData) => { + return http.post('/api/v1/pig-batches', batchData); +}; + +/** + * 根据ID获取单个猪批次信息 + * @param {number} id - 猪批次ID + * @returns {Promise<*>} + */ +export const getPigBatchById = (id) => { + return http.get(`/api/v1/pig-batches/${id}`); +}; + +/** + * 更新一个已存在的猪批次信息 + * @param {number} id - 猪批次ID + * @param {object} batchData - 猪批次信息,对应 dto.PigBatchUpdateDTO + * @returns {Promise<*>} + */ +export const updatePigBatch = (id, batchData) => { + return http.put(`/api/v1/pig-batches/${id}`, batchData); +}; + +/** + * 根据ID删除一个猪批次 + * @param {number} id - 猪批次ID + * @returns {Promise<*>} + */ +export const deletePigBatch = (id) => { + return http.delete(`/api/v1/pig-batches/${id}`); +}; + +// --- 猪批次业务操作 --- + +/** + * 为猪批次分配空栏 + * @param {number} id - 猪批次ID + * @param {object} pensData - 待分配的猪栏ID列表,对应 dto.AssignEmptyPensToBatchRequest + * @returns {Promise<*>} + */ +export const assignPensToBatch = (id, pensData) => { + return http.post(`/api/v1/pig-batches/assign-pens/${id}`, pensData); +}; + +/** + * 从猪批次移除空栏 + * @param {number} batchID - 猪批次ID + * @param {number} penID - 待移除的猪栏ID + * @returns {Promise<*>} + */ +export const removePenFromBatch = (batchID, penID) => { + return http.delete(`/api/v1/pig-batches/remove-pen/${penID}/${batchID}`); +}; + +/** + * 处理买猪的业务逻辑 + * @param {number} id - 猪批次ID + * @param {object} buyData - 买猪请求信息,对应 dto.BuyPigsRequest + * @returns {Promise<*>} + */ +export const buyPigsForBatch = (id, buyData) => { + return http.post(`/api/v1/pig-batches/buy-pigs/${id}`, buyData); +}; + +/** + * 处理卖猪的业务逻辑 + * @param {number} id - 猪批次ID + * @param {object} sellData - 卖猪请求信息,对应 dto.SellPigsRequest + * @returns {Promise<*>} + */ +export const sellPigsFromBatch = (id, sellData) => { + return http.post(`/api/v1/pig-batches/sell-pigs/${id}`, sellData); +}; + +/** + * 将猪只从“虚拟库存”移入指定猪栏 + * @param {number} id - 猪批次ID + * @param {object} moveData - 移入猪只请求信息,对应 dto.MovePigsIntoPenRequest + * @returns {Promise<*>} + */ +export const movePigsIntoPen = (id, moveData) => { + return http.post(`/api/v1/pig-batches/move-pigs-into-pen/${id}`, moveData); +}; + +/** + * 群内调栏 + * @param {number} id - 猪批次ID + * @param {object} transferData - 群内调栏请求信息,对应 dto.TransferPigsWithinBatchRequest + * @returns {Promise<*>} + */ +export const transferPigsWithinBatch = (id, transferData) => { + return http.post(`/api/v1/pig-batches/transfer-within-batch/${id}`, transferData); +}; + +/** + * 跨猪群调栏 + * @param {number} sourceBatchID - 源猪批次ID + * @param {object} transferData - 跨群调栏请求信息,对应 dto.TransferPigsAcrossBatchesRequest + * @returns {Promise<*>} + */ +export const transferPigsAcrossBatches = (sourceBatchID, transferData) => { + return http.post(`/api/v1/pig-batches/transfer-across-batches/${sourceBatchID}`, transferData); +}; + +/** + * 将猪栏划拨到新批次 + * @param {number} fromBatchID - 源猪批次ID + * @param {object} reclassifyData - 划拨请求信息,对应 dto.ReclassifyPenToNewBatchRequest + * @returns {Promise<*>} + */ +export const reclassifyPenToNewBatch = (fromBatchID, reclassifyData) => { + return http.post(`/api/v1/pig-batches/reclassify-pen/${fromBatchID}`, reclassifyData); +}; + +// --- 猪只数量变更记录 --- + +/** + * 记录新增病猪事件 + * @param {number} id - 猪批次ID + * @param {object} sickData - 记录病猪请求信息,对应 dto.RecordSickPigsRequest + * @returns {Promise<*>} + */ +export const recordSickPigsInBatch = (id, sickData) => { + return http.post(`/api/v1/pig-batches/record-sick-pigs/${id}`, sickData); +}; + +/** + * 记录病猪康复事件 + * @param {number} id - 猪批次ID + * @param {object} recoveryData - 记录病猪康复请求信息,对应 dto.RecordSickPigRecoveryRequest + * @returns {Promise<*>} + */ +export const recordSickPigRecoveryInBatch = (id, recoveryData) => { + return http.post(`/api/v1/pig-batches/record-sick-pig-recovery/${id}`, recoveryData); +}; + +/** + * 记录病猪死亡事件 + * @param {number} id - 猪批次ID + * @param {object} deathData - 记录病猪死亡请求信息,对应 dto.RecordSickPigDeathRequest + * @returns {Promise<*>} + */ +export const recordSickPigDeathInBatch = (id, deathData) => { + return http.post(`/api/v1/pig-batches/record-sick-pig-death/${id}`, deathData); +}; + +/** + * 记录病猪淘汰事件 + * @param {number} id - 猪批次ID + * @param {object} cullData - 记录病猪淘汰请求信息,对应 dto.RecordSickPigCullRequest + * @returns {Promise<*>} + */ +export const recordSickPigCullInBatch = (id, cullData) => { + return http.post(`/api/v1/pig-batches/record-sick-pig-cull/${id}`, cullData); +}; + +/** + * 记录正常猪只死亡事件 + * @param {number} id - 猪批次ID + * @param {object} deathData - 记录正常猪只死亡请求信息,对应 dto.RecordDeathRequest + * @returns {Promise<*>} + */ +export const recordDeathInBatch = (id, deathData) => { + return http.post(`/api/v1/pig-batches/record-death/${id}`, deathData); +}; + +/** + * 记录正常猪只淘汰事件 + * @param {number} id - 猪批次ID + * @param {object} cullData - 记录正常猪只淘汰请求信息,对应 dto.RecordCullRequest + * @returns {Promise<*>} + */ +export const recordCullInBatch = (id, cullData) => { + return http.post(`/api/v1/pig-batches/record-cull/${id}`, cullData); +}; diff --git a/src/api/pigHouse.js b/src/api/pigHouse.js new file mode 100644 index 00000000..ee314541 --- /dev/null +++ b/src/api/pigHouse.js @@ -0,0 +1,46 @@ +import http from '../utils/http'; + +/** + * 获取所有猪舍的列表 + * @returns {Promise<*>} + */ +export const getPigHouses = () => { + return http.get('/api/v1/pig-houses'); +}; + +/** + * 创建一个新的猪舍 + * @param {object} pigHouseData - 猪舍信息,对应 dto.CreatePigHouseRequest + * @returns {Promise<*>} + */ +export const createPigHouse = (pigHouseData) => { + return http.post('/api/v1/pig-houses', pigHouseData); +}; + +/** + * 根据ID获取单个猪舍信息 + * @param {number} id - 猪舍ID + * @returns {Promise<*>} + */ +export const getPigHouseById = (id) => { + return http.get(`/api/v1/pig-houses/${id}`); +}; + +/** + * 更新一个已存在的猪舍信息 + * @param {number} id - 猪舍ID + * @param {object} pigHouseData - 猪舍信息,对应 dto.UpdatePigHouseRequest + * @returns {Promise<*>} + */ +export const updatePigHouse = (id, pigHouseData) => { + return http.put(`/api/v1/pig-houses/${id}`, pigHouseData); +}; + +/** + * 根据ID删除一个猪舍 + * @param {number} id - 猪舍ID + * @returns {Promise<*>} + */ +export const deletePigHouse = (id) => { + return http.delete(`/api/v1/pig-houses/${id}`); +}; diff --git a/src/api/plan.js b/src/api/plan.js index d665508f..fdd692ec 100644 --- a/src/api/plan.js +++ b/src/api/plan.js @@ -1,71 +1,64 @@ -import http from '../utils/http.js'; +import http from '../utils/http'; /** - * 计划管理API + * 获取所有计划的列表 + * @returns {Promise<*>} */ -export class PlanApi { - /** - * 获取计划列表 - * @returns {Promise} 计划列表 - */ - static list() { - return http.get('/api/v1/plans'); - } +export const getPlans = () => { + return http.get('/api/v1/plans'); +}; - /** - * 创建新计划 - * @param {Object} planData 计划数据 - * @returns {Promise} 创建结果 - */ - static create(planData) { - return http.post('/api/v1/plans', planData); - } +/** + * 创建一个新的计划 + * @param {object} planData - 计划信息,对应 dto.CreatePlanRequest + * @returns {Promise<*>} + */ +export const createPlan = (planData) => { + return http.post('/api/v1/plans', planData); +}; - /** - * 获取计划详情 - * @param {string|number} id 计划ID - * @returns {Promise} 计划详情 - */ - static get(id) { - return http.get(`/api/v1/plans/${id}`); - } +/** + * 根据计划ID获取单个计划的详细信息 + * @param {number} id - 计划ID + * @returns {Promise<*>} + */ +export const getPlanById = (id) => { + return http.get(`/api/v1/plans/${id}`); +}; - /** - * 更新计划信息 - * @param {string|number} id 计划ID - * @param {Object} planData 计划数据 - * @returns {Promise} 更新结果 - */ - static update(id, planData) { - return http.put(`/api/v1/plans/${id}`, planData); - } +/** + * 根据计划ID更新计划的详细信息 + * @param {number} id - 计划ID + * @param {object} planData - 更新后的计划信息,对应 dto.UpdatePlanRequest + * @returns {Promise<*>} + */ +export const updatePlan = (id, planData) => { + return http.put(`/api/v1/plans/${id}`, planData); +}; - /** - * 删除计划 - * @param {string|number} id 计划ID - * @returns {Promise} 删除结果 - */ - static delete(id) { - return http.delete(`/api/v1/plans/${id}`); - } +/** + * 根据计划ID删除计划(软删除) + * @param {number} id - 计划ID + * @returns {Promise<*>} + */ +export const deletePlan = (id) => { + return http.delete(`/api/v1/plans/${id}`); +}; - /** - * 启动计划 - * @param {string|number} id 计划ID - * @returns {Promise} 启动结果 - */ - static start(id) { - return http.post(`/api/v1/plans/${id}/start`); - } +/** + * 根据计划ID启动一个计划的执行 + * @param {number} id - 计划ID + * @returns {Promise<*>} + */ +export const startPlan = (id) => { + return http.post(`/api/v1/plans/${id}/start`); +}; - /** - * 停止计划 - * @param {string|number} id 计划ID - * @returns {Promise} 停止结果 - */ - static stop(id) { - return http.post(`/api/v1/plans/${id}/stop`); - } -} - -export default PlanApi; \ No newline at end of file +/** + * 根据计划ID停止一个正在执行的计划 + * @param {number} id - 计划ID + * @returns {Promise<*>} + */ +export const stopPlan = (id) => { + return http.post(`/api/v1/plans/${id}/stop`); +}; diff --git a/src/api/user.js b/src/api/user.js index a99e716a..466d5fef 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -1,26 +1,29 @@ -import http from '../utils/http.js'; +import http from '../utils/http'; /** - * 用户管理API + * 创建一个新用户 + * @param {object} userData - 用户信息,对应 dto.CreateUserRequest + * @returns {Promise<*>} */ -export class UserApi { - /** - * 创建新用户 - * @param {Object} userData 用户数据 - * @returns {Promise} 创建结果 - */ - static create(userData) { - return http.post('/api/v1/users', userData); - } +export const createUser = (userData) => { + return http.post('/api/v1/users', userData); +}; - /** - * 用户登录 - * @param {Object} credentials 登录凭证 {username, password} - * @returns {Promise} 登录结果 - */ - static login(credentials) { - return http.post('/api/v1/users/login', credentials); - } -} +/** + * 用户登录 + * @param {object} credentials - 登录凭证,对应 dto.LoginRequest + * @returns {Promise<*>} + */ +export const login = (credentials) => { + return http.post('/api/v1/users/login', credentials); +}; -export default UserApi; \ No newline at end of file +/** + * 获取指定用户的操作历史 + * @param {number} id - 用户ID + * @param {object} params - 查询参数 + * @returns {Promise<*>} + */ +export const getUserHistory = (id, params) => { + return http.get(`/api/v1/users/${id}/history`, { params }); +};