diff --git a/config.yml b/config.yml index a3aa9e2..0820e69 100644 --- a/config.yml +++ b/config.yml @@ -66,7 +66,7 @@ lora: lora_mesh: # 主节点串口 - uart_port: "/dev/ttyS1" + uart_port: "COM7" # LoRa模块的通信波特率 baud_rate: 9600 # 等待LoRa模块AT指令响应的超时时间(ms) diff --git a/internal/app/api/api.go b/internal/app/api/api.go index 53da648..ecc7d37 100644 --- a/internal/app/api/api.go +++ b/internal/app/api/api.go @@ -234,20 +234,20 @@ func (a *API) setupRoutes() { pigBatchGroup.GET("/:id", a.pigBatchController.GetPigBatch) // 获取单个猪群 pigBatchGroup.PUT("/:id", a.pigBatchController.UpdatePigBatch) // 更新猪群 pigBatchGroup.DELETE("/:id", a.pigBatchController.DeletePigBatch) // 删除猪群 - pigBatchGroup.POST("/:id/assign-pens", a.pigBatchController.AssignEmptyPensToBatch) // 为猪群分配空栏 - pigBatchGroup.POST("/:fromBatchID/reclassify-pen", a.pigBatchController.ReclassifyPenToNewBatch) // 将猪栏划拨到新群 - pigBatchGroup.DELETE("/:batchID/remove-pen/:penID", a.pigBatchController.RemoveEmptyPenFromBatch) // 从猪群移除空栏 - pigBatchGroup.POST("/:id/move-pigs-into-pen", a.pigBatchController.MovePigsIntoPen) // 将猪只从“虚拟库存”移入指定猪栏 - pigBatchGroup.POST("/:id/sell-pigs", a.pigBatchController.SellPigs) // 处理卖猪业务 - pigBatchGroup.POST("/:id/buy-pigs", a.pigBatchController.BuyPigs) // 处理买猪业务 - pigBatchGroup.POST("/:sourceBatchID/transfer-across-batches", a.pigBatchController.TransferPigsAcrossBatches) // 跨猪群调栏 - pigBatchGroup.POST("/:id/transfer-within-batch", a.pigBatchController.TransferPigsWithinBatch) // 群内调栏 - pigBatchGroup.POST("/:id/record-sick-pigs", a.pigBatchController.RecordSickPigs) // 记录新增病猪事件 - pigBatchGroup.POST("/:id/record-sick-pig-recovery", a.pigBatchController.RecordSickPigRecovery) // 记录病猪康复事件 - pigBatchGroup.POST("/:id/record-sick-pig-death", a.pigBatchController.RecordSickPigDeath) // 记录病猪死亡事件 - pigBatchGroup.POST("/:id/record-sick-pig-cull", a.pigBatchController.RecordSickPigCull) // 记录病猪淘汰事件 - pigBatchGroup.POST("/:id/record-death", a.pigBatchController.RecordDeath) // 记录正常猪只死亡事件 - pigBatchGroup.POST("/:id/record-cull", a.pigBatchController.RecordCull) // 记录正常猪只淘汰事件 + pigBatchGroup.POST("/assign-pens/:id", a.pigBatchController.AssignEmptyPensToBatch) // 为猪群分配空栏 + pigBatchGroup.POST("/reclassify-pen/:fromBatchID", a.pigBatchController.ReclassifyPenToNewBatch) // 将猪栏划拨到新群 + pigBatchGroup.DELETE("/remove-pen/:penID/:batchID", a.pigBatchController.RemoveEmptyPenFromBatch) // 从猪群移除空栏 + pigBatchGroup.POST("/move-pigs-into-pen/:id", a.pigBatchController.MovePigsIntoPen) // 将猪只从“虚拟库存”移入指定猪栏 + pigBatchGroup.POST("/sell-pigs/:id", a.pigBatchController.SellPigs) // 处理卖猪业务 + pigBatchGroup.POST("/buy-pigs/:id", a.pigBatchController.BuyPigs) // 处理买猪业务 + pigBatchGroup.POST("/transfer-across-batches/:sourceBatchID", a.pigBatchController.TransferPigsAcrossBatches) // 跨猪群调栏 + pigBatchGroup.POST("/transfer-within-batch/:id", a.pigBatchController.TransferPigsWithinBatch) // 群内调栏 + pigBatchGroup.POST("/record-sick-pigs/:id", a.pigBatchController.RecordSickPigs) // 记录新增病猪事件 + pigBatchGroup.POST("/record-sick-pig-recovery/:id", a.pigBatchController.RecordSickPigRecovery) // 记录病猪康复事件 + pigBatchGroup.POST("/record-sick-pig-death/:id", a.pigBatchController.RecordSickPigDeath) // 记录病猪死亡事件 + pigBatchGroup.POST("/record-sick-pig-cull/:id", a.pigBatchController.RecordSickPigCull) // 记录病猪淘汰事件 + pigBatchGroup.POST("/record-death/:id", a.pigBatchController.RecordDeath) // 记录正常猪只死亡事件 + pigBatchGroup.POST("/record-cull/:id", a.pigBatchController.RecordCull) // 记录正常猪只淘汰事件 } a.logger.Info("猪群相关接口注册成功 (需要认证和审计)") diff --git a/internal/app/controller/management/pig_batch_controller.go b/internal/app/controller/management/pig_batch_controller.go index 79a6bff..6b1bf8e 100644 --- a/internal/app/controller/management/pig_batch_controller.go +++ b/internal/app/controller/management/pig_batch_controller.go @@ -55,7 +55,7 @@ func (c *PigBatchController) CreatePigBatch(ctx *gin.Context) { // @Produce json // @Param id path int true "猪批次ID" // @Success 200 {object} controller.Response{data=dto.PigBatchResponseDTO} "获取成功" -// @Router /api/v1/pig-batches/{id} [get]\ +// @Router /api/v1/pig-batches/{id} [get] func (c *PigBatchController) GetPigBatch(ctx *gin.Context) { const action = "获取猪批次" @@ -144,7 +144,7 @@ func (c *PigBatchController) ListPigBatches(ctx *gin.Context) { // @Param id path int true "猪批次ID" // @Param body body dto.AssignEmptyPensToBatchRequest true "待分配的猪栏ID列表" // @Success 200 {object} controller.Response "分配成功" -// @Router /api/v1/pig-batches/{id}/assign-pens [post] +// @Router /api/v1/pig-batches/assign-pens/{id} [post] func (c *PigBatchController) AssignEmptyPensToBatch(ctx *gin.Context) { const action = "为猪批次分配空栏" var req dto.AssignEmptyPensToBatchRequest @@ -168,7 +168,7 @@ func (c *PigBatchController) AssignEmptyPensToBatch(ctx *gin.Context) { // @Param fromBatchID path int true "源猪批次ID" // @Param body body dto.ReclassifyPenToNewBatchRequest true "划拨请求信息 (包含目标批次ID、猪栏ID和备注)" // @Success 200 {object} controller.Response "划拨成功" -// @Router /api/v1/pig-batches/{fromBatchID}/reclassify-pen [post] +// @Router /api/v1/pig-batches/reclassify-pen/{fromBatchID} [post] func (c *PigBatchController) ReclassifyPenToNewBatch(ctx *gin.Context) { const action = "划拨猪栏到新批次" var req dto.ReclassifyPenToNewBatchRequest @@ -199,7 +199,7 @@ func (c *PigBatchController) ReclassifyPenToNewBatch(ctx *gin.Context) { // @Param batchID path int true "猪批次ID" // @Param penID path int true "待移除的猪栏ID" // @Success 200 {object} controller.Response "移除成功" -// @Router /api/v1/pig-batches/{batchID}/remove-pen/{penID} [delete] +// @Router /api/v1/pig-batches/remove-pen/{penID}/{batchID} [delete] func (c *PigBatchController) RemoveEmptyPenFromBatch(ctx *gin.Context) { const action = "从猪批次移除空栏" @@ -235,7 +235,7 @@ func (c *PigBatchController) RemoveEmptyPenFromBatch(ctx *gin.Context) { // @Param id path int true "猪批次ID" // @Param body body dto.MovePigsIntoPenRequest true "移入猪只请求信息 (包含目标猪栏ID、数量和备注)" // @Success 200 {object} controller.Response "移入成功" -// @Router /api/v1/pig-batches/{id}/move-pigs-into-pen [post] +// @Router /api/v1/pig-batches/move-pigs-into-pen/{id} [post] func (c *PigBatchController) MovePigsIntoPen(ctx *gin.Context) { const action = "将猪只移入猪栏" var req dto.MovePigsIntoPenRequest diff --git a/internal/app/controller/management/pig_batch_health_controller.go b/internal/app/controller/management/pig_batch_health_controller.go index 0bcff82..dd8c235 100644 --- a/internal/app/controller/management/pig_batch_health_controller.go +++ b/internal/app/controller/management/pig_batch_health_controller.go @@ -14,7 +14,7 @@ import ( // @Param id path int true "猪批次ID" // @Param body body dto.RecordSickPigsRequest true "记录病猪请求信息" // @Success 200 {object} controller.Response "记录成功" -// @Router /api/v1/pig-batches/{id}/record-sick-pigs [post] +// @Router /api/v1/pig-batches/record-sick-pigs/{id} [post] func (c *PigBatchController) RecordSickPigs(ctx *gin.Context) { const action = "记录新增病猪事件" var req dto.RecordSickPigsRequest @@ -38,7 +38,7 @@ func (c *PigBatchController) RecordSickPigs(ctx *gin.Context) { // @Param id path int true "猪批次ID" // @Param body body dto.RecordSickPigRecoveryRequest true "记录病猪康复请求信息" // @Success 200 {object} controller.Response "记录成功" -// @Router /api/v1/pig-batches/{id}/record-sick-pig-recovery [post] +// @Router /api/v1/pig-batches/record-sick-pig-recovery/{id} [post] func (c *PigBatchController) RecordSickPigRecovery(ctx *gin.Context) { const action = "记录病猪康复事件" var req dto.RecordSickPigRecoveryRequest @@ -62,7 +62,7 @@ func (c *PigBatchController) RecordSickPigRecovery(ctx *gin.Context) { // @Param id path int true "猪批次ID" // @Param body body dto.RecordSickPigDeathRequest true "记录病猪死亡请求信息" // @Success 200 {object} controller.Response "记录成功" -// @Router /api/v1/pig-batches/{id}/record-sick-pig-death [post] +// @Router /api/v1/pig-batches/record-sick-pig-death/{id} [post] func (c *PigBatchController) RecordSickPigDeath(ctx *gin.Context) { const action = "记录病猪死亡事件" var req dto.RecordSickPigDeathRequest @@ -86,7 +86,7 @@ func (c *PigBatchController) RecordSickPigDeath(ctx *gin.Context) { // @Param id path int true "猪批次ID" // @Param body body dto.RecordSickPigCullRequest true "记录病猪淘汰请求信息" // @Success 200 {object} controller.Response "记录成功" -// @Router /api/v1/pig-batches/{id}/record-sick-pig-cull [post] +// @Router /api/v1/pig-batches/record-sick-pig-cull/{id} [post] func (c *PigBatchController) RecordSickPigCull(ctx *gin.Context) { const action = "记录病猪淘汰事件" var req dto.RecordSickPigCullRequest @@ -110,7 +110,7 @@ func (c *PigBatchController) RecordSickPigCull(ctx *gin.Context) { // @Param id path int true "猪批次ID" // @Param body body dto.RecordDeathRequest true "记录正常猪只死亡请求信息" // @Success 200 {object} controller.Response "记录成功" -// @Router /api/v1/pig-batches/{id}/record-death [post] +// @Router /api/v1/pig-batches/record-death/{id} [post] func (c *PigBatchController) RecordDeath(ctx *gin.Context) { const action = "记录正常猪只死亡事件" var req dto.RecordDeathRequest @@ -134,7 +134,7 @@ func (c *PigBatchController) RecordDeath(ctx *gin.Context) { // @Param id path int true "猪批次ID" // @Param body body dto.RecordCullRequest true "记录正常猪只淘汰请求信息" // @Success 200 {object} controller.Response "记录成功" -// @Router /api/v1/pig-batches/{id}/record-cull [post] +// @Router /api/v1/pig-batches/record-cull/{id} [post] func (c *PigBatchController) RecordCull(ctx *gin.Context) { const action = "记录正常猪只淘汰事件" var req dto.RecordCullRequest diff --git a/internal/app/controller/management/pig_batch_trade_controller.go b/internal/app/controller/management/pig_batch_trade_controller.go index 74e5bd8..2db82af 100644 --- a/internal/app/controller/management/pig_batch_trade_controller.go +++ b/internal/app/controller/management/pig_batch_trade_controller.go @@ -14,7 +14,7 @@ import ( // @Param id path int true "猪批次ID" // @Param body body dto.SellPigsRequest true "卖猪请求信息" // @Success 200 {object} controller.Response "卖猪成功" -// @Router /api/v1/pig-batches/{id}/sell-pigs [post] +// @Router /api/v1/pig-batches/sell-pigs/{id} [post] func (c *PigBatchController) SellPigs(ctx *gin.Context) { const action = "卖猪" var req dto.SellPigsRequest @@ -38,7 +38,7 @@ func (c *PigBatchController) SellPigs(ctx *gin.Context) { // @Param id path int true "猪批次ID" // @Param body body dto.BuyPigsRequest true "买猪请求信息" // @Success 200 {object} controller.Response "买猪成功" -// @Router /api/v1/pig-batches/{id}/buy-pigs [post] +// @Router /api/v1/pig-batches/buy-pigs/{id} [post] func (c *PigBatchController) BuyPigs(ctx *gin.Context) { const action = "买猪" var req dto.BuyPigsRequest diff --git a/internal/app/controller/management/pig_batch_transfer_controller.go b/internal/app/controller/management/pig_batch_transfer_controller.go index 9089791..4d5cc3e 100644 --- a/internal/app/controller/management/pig_batch_transfer_controller.go +++ b/internal/app/controller/management/pig_batch_transfer_controller.go @@ -16,7 +16,7 @@ import ( // @Param sourceBatchID path int true "源猪批次ID" // @Param body body dto.TransferPigsAcrossBatchesRequest true "跨群调栏请求信息" // @Success 200 {object} controller.Response "调栏成功" -// @Router /api/v1/pig-batches/{sourceBatchID}/transfer-across-batches [post] +// @Router /api/v1/pig-batches/transfer-across-batches/{sourceBatchID} [post] func (c *PigBatchController) TransferPigsAcrossBatches(ctx *gin.Context) { const action = "跨猪群调栏" var req dto.TransferPigsAcrossBatchesRequest @@ -48,7 +48,7 @@ func (c *PigBatchController) TransferPigsAcrossBatches(ctx *gin.Context) { // @Param id path int true "猪批次ID" // @Param body body dto.TransferPigsWithinBatchRequest true "群内调栏请求信息" // @Success 200 {object} controller.Response "调栏成功" -// @Router /api/v1/pig-batches/{id}/transfer-within-batch [post] +// @Router /api/v1/pig-batches/transfer-within-batch/{id} [post] func (c *PigBatchController) TransferPigsWithinBatch(ctx *gin.Context) { const action = "群内调栏" var req dto.TransferPigsWithinBatchRequest