处理路由冲突

This commit is contained in:
2025-10-10 18:23:06 +08:00
parent 6d8cb7ca4e
commit b4d31d3133
6 changed files with 30 additions and 30 deletions

View File

@@ -66,7 +66,7 @@ lora:
lora_mesh: lora_mesh:
# 主节点串口 # 主节点串口
uart_port: "/dev/ttyS1" uart_port: "COM7"
# LoRa模块的通信波特率 # LoRa模块的通信波特率
baud_rate: 9600 baud_rate: 9600
# 等待LoRa模块AT指令响应的超时时间(ms) # 等待LoRa模块AT指令响应的超时时间(ms)

View File

@@ -234,20 +234,20 @@ func (a *API) setupRoutes() {
pigBatchGroup.GET("/:id", a.pigBatchController.GetPigBatch) // 获取单个猪群 pigBatchGroup.GET("/:id", a.pigBatchController.GetPigBatch) // 获取单个猪群
pigBatchGroup.PUT("/:id", a.pigBatchController.UpdatePigBatch) // 更新猪群 pigBatchGroup.PUT("/:id", a.pigBatchController.UpdatePigBatch) // 更新猪群
pigBatchGroup.DELETE("/:id", a.pigBatchController.DeletePigBatch) // 删除猪群 pigBatchGroup.DELETE("/:id", a.pigBatchController.DeletePigBatch) // 删除猪群
pigBatchGroup.POST("/:id/assign-pens", a.pigBatchController.AssignEmptyPensToBatch) // 为猪群分配空栏 pigBatchGroup.POST("/assign-pens/:id", a.pigBatchController.AssignEmptyPensToBatch) // 为猪群分配空栏
pigBatchGroup.POST("/:fromBatchID/reclassify-pen", a.pigBatchController.ReclassifyPenToNewBatch) // 将猪栏划拨到新群 pigBatchGroup.POST("/reclassify-pen/:fromBatchID", a.pigBatchController.ReclassifyPenToNewBatch) // 将猪栏划拨到新群
pigBatchGroup.DELETE("/:batchID/remove-pen/:penID", a.pigBatchController.RemoveEmptyPenFromBatch) // 从猪群移除空栏 pigBatchGroup.DELETE("/remove-pen/:penID/:batchID", a.pigBatchController.RemoveEmptyPenFromBatch) // 从猪群移除空栏
pigBatchGroup.POST("/:id/move-pigs-into-pen", a.pigBatchController.MovePigsIntoPen) // 将猪只从“虚拟库存”移入指定猪栏 pigBatchGroup.POST("/move-pigs-into-pen/:id", a.pigBatchController.MovePigsIntoPen) // 将猪只从“虚拟库存”移入指定猪栏
pigBatchGroup.POST("/:id/sell-pigs", a.pigBatchController.SellPigs) // 处理卖猪业务 pigBatchGroup.POST("/sell-pigs/:id", a.pigBatchController.SellPigs) // 处理卖猪业务
pigBatchGroup.POST("/:id/buy-pigs", a.pigBatchController.BuyPigs) // 处理买猪业务 pigBatchGroup.POST("/buy-pigs/:id", a.pigBatchController.BuyPigs) // 处理买猪业务
pigBatchGroup.POST("/:sourceBatchID/transfer-across-batches", a.pigBatchController.TransferPigsAcrossBatches) // 跨猪群调栏 pigBatchGroup.POST("/transfer-across-batches/:sourceBatchID", a.pigBatchController.TransferPigsAcrossBatches) // 跨猪群调栏
pigBatchGroup.POST("/:id/transfer-within-batch", a.pigBatchController.TransferPigsWithinBatch) // 群内调栏 pigBatchGroup.POST("/transfer-within-batch/:id", a.pigBatchController.TransferPigsWithinBatch) // 群内调栏
pigBatchGroup.POST("/:id/record-sick-pigs", a.pigBatchController.RecordSickPigs) // 记录新增病猪事件 pigBatchGroup.POST("/record-sick-pigs/:id", a.pigBatchController.RecordSickPigs) // 记录新增病猪事件
pigBatchGroup.POST("/:id/record-sick-pig-recovery", a.pigBatchController.RecordSickPigRecovery) // 记录病猪康复事件 pigBatchGroup.POST("/record-sick-pig-recovery/:id", a.pigBatchController.RecordSickPigRecovery) // 记录病猪康复事件
pigBatchGroup.POST("/:id/record-sick-pig-death", a.pigBatchController.RecordSickPigDeath) // 记录病猪死亡事件 pigBatchGroup.POST("/record-sick-pig-death/:id", a.pigBatchController.RecordSickPigDeath) // 记录病猪死亡事件
pigBatchGroup.POST("/:id/record-sick-pig-cull", a.pigBatchController.RecordSickPigCull) // 记录病猪淘汰事件 pigBatchGroup.POST("/record-sick-pig-cull/:id", a.pigBatchController.RecordSickPigCull) // 记录病猪淘汰事件
pigBatchGroup.POST("/:id/record-death", a.pigBatchController.RecordDeath) // 记录正常猪只死亡事件 pigBatchGroup.POST("/record-death/:id", a.pigBatchController.RecordDeath) // 记录正常猪只死亡事件
pigBatchGroup.POST("/:id/record-cull", a.pigBatchController.RecordCull) // 记录正常猪只淘汰事件 pigBatchGroup.POST("/record-cull/:id", a.pigBatchController.RecordCull) // 记录正常猪只淘汰事件
} }
a.logger.Info("猪群相关接口注册成功 (需要认证和审计)") a.logger.Info("猪群相关接口注册成功 (需要认证和审计)")

View File

@@ -55,7 +55,7 @@ func (c *PigBatchController) CreatePigBatch(ctx *gin.Context) {
// @Produce json // @Produce json
// @Param id path int true "猪批次ID" // @Param id path int true "猪批次ID"
// @Success 200 {object} controller.Response{data=dto.PigBatchResponseDTO} "获取成功" // @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) { func (c *PigBatchController) GetPigBatch(ctx *gin.Context) {
const action = "获取猪批次" const action = "获取猪批次"
@@ -144,7 +144,7 @@ func (c *PigBatchController) ListPigBatches(ctx *gin.Context) {
// @Param id path int true "猪批次ID" // @Param id path int true "猪批次ID"
// @Param body body dto.AssignEmptyPensToBatchRequest true "待分配的猪栏ID列表" // @Param body body dto.AssignEmptyPensToBatchRequest true "待分配的猪栏ID列表"
// @Success 200 {object} controller.Response "分配成功" // @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) { func (c *PigBatchController) AssignEmptyPensToBatch(ctx *gin.Context) {
const action = "为猪批次分配空栏" const action = "为猪批次分配空栏"
var req dto.AssignEmptyPensToBatchRequest var req dto.AssignEmptyPensToBatchRequest
@@ -168,7 +168,7 @@ func (c *PigBatchController) AssignEmptyPensToBatch(ctx *gin.Context) {
// @Param fromBatchID path int true "源猪批次ID" // @Param fromBatchID path int true "源猪批次ID"
// @Param body body dto.ReclassifyPenToNewBatchRequest true "划拨请求信息 (包含目标批次ID、猪栏ID和备注)" // @Param body body dto.ReclassifyPenToNewBatchRequest true "划拨请求信息 (包含目标批次ID、猪栏ID和备注)"
// @Success 200 {object} controller.Response "划拨成功" // @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) { func (c *PigBatchController) ReclassifyPenToNewBatch(ctx *gin.Context) {
const action = "划拨猪栏到新批次" const action = "划拨猪栏到新批次"
var req dto.ReclassifyPenToNewBatchRequest var req dto.ReclassifyPenToNewBatchRequest
@@ -199,7 +199,7 @@ func (c *PigBatchController) ReclassifyPenToNewBatch(ctx *gin.Context) {
// @Param batchID path int true "猪批次ID" // @Param batchID path int true "猪批次ID"
// @Param penID path int true "待移除的猪栏ID" // @Param penID path int true "待移除的猪栏ID"
// @Success 200 {object} controller.Response "移除成功" // @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) { func (c *PigBatchController) RemoveEmptyPenFromBatch(ctx *gin.Context) {
const action = "从猪批次移除空栏" const action = "从猪批次移除空栏"
@@ -235,7 +235,7 @@ func (c *PigBatchController) RemoveEmptyPenFromBatch(ctx *gin.Context) {
// @Param id path int true "猪批次ID" // @Param id path int true "猪批次ID"
// @Param body body dto.MovePigsIntoPenRequest true "移入猪只请求信息 (包含目标猪栏ID、数量和备注)" // @Param body body dto.MovePigsIntoPenRequest true "移入猪只请求信息 (包含目标猪栏ID、数量和备注)"
// @Success 200 {object} controller.Response "移入成功" // @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) { func (c *PigBatchController) MovePigsIntoPen(ctx *gin.Context) {
const action = "将猪只移入猪栏" const action = "将猪只移入猪栏"
var req dto.MovePigsIntoPenRequest var req dto.MovePigsIntoPenRequest

View File

@@ -14,7 +14,7 @@ import (
// @Param id path int true "猪批次ID" // @Param id path int true "猪批次ID"
// @Param body body dto.RecordSickPigsRequest true "记录病猪请求信息" // @Param body body dto.RecordSickPigsRequest true "记录病猪请求信息"
// @Success 200 {object} controller.Response "记录成功" // @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) { func (c *PigBatchController) RecordSickPigs(ctx *gin.Context) {
const action = "记录新增病猪事件" const action = "记录新增病猪事件"
var req dto.RecordSickPigsRequest var req dto.RecordSickPigsRequest
@@ -38,7 +38,7 @@ func (c *PigBatchController) RecordSickPigs(ctx *gin.Context) {
// @Param id path int true "猪批次ID" // @Param id path int true "猪批次ID"
// @Param body body dto.RecordSickPigRecoveryRequest true "记录病猪康复请求信息" // @Param body body dto.RecordSickPigRecoveryRequest true "记录病猪康复请求信息"
// @Success 200 {object} controller.Response "记录成功" // @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) { func (c *PigBatchController) RecordSickPigRecovery(ctx *gin.Context) {
const action = "记录病猪康复事件" const action = "记录病猪康复事件"
var req dto.RecordSickPigRecoveryRequest var req dto.RecordSickPigRecoveryRequest
@@ -62,7 +62,7 @@ func (c *PigBatchController) RecordSickPigRecovery(ctx *gin.Context) {
// @Param id path int true "猪批次ID" // @Param id path int true "猪批次ID"
// @Param body body dto.RecordSickPigDeathRequest true "记录病猪死亡请求信息" // @Param body body dto.RecordSickPigDeathRequest true "记录病猪死亡请求信息"
// @Success 200 {object} controller.Response "记录成功" // @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) { func (c *PigBatchController) RecordSickPigDeath(ctx *gin.Context) {
const action = "记录病猪死亡事件" const action = "记录病猪死亡事件"
var req dto.RecordSickPigDeathRequest var req dto.RecordSickPigDeathRequest
@@ -86,7 +86,7 @@ func (c *PigBatchController) RecordSickPigDeath(ctx *gin.Context) {
// @Param id path int true "猪批次ID" // @Param id path int true "猪批次ID"
// @Param body body dto.RecordSickPigCullRequest true "记录病猪淘汰请求信息" // @Param body body dto.RecordSickPigCullRequest true "记录病猪淘汰请求信息"
// @Success 200 {object} controller.Response "记录成功" // @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) { func (c *PigBatchController) RecordSickPigCull(ctx *gin.Context) {
const action = "记录病猪淘汰事件" const action = "记录病猪淘汰事件"
var req dto.RecordSickPigCullRequest var req dto.RecordSickPigCullRequest
@@ -110,7 +110,7 @@ func (c *PigBatchController) RecordSickPigCull(ctx *gin.Context) {
// @Param id path int true "猪批次ID" // @Param id path int true "猪批次ID"
// @Param body body dto.RecordDeathRequest true "记录正常猪只死亡请求信息" // @Param body body dto.RecordDeathRequest true "记录正常猪只死亡请求信息"
// @Success 200 {object} controller.Response "记录成功" // @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) { func (c *PigBatchController) RecordDeath(ctx *gin.Context) {
const action = "记录正常猪只死亡事件" const action = "记录正常猪只死亡事件"
var req dto.RecordDeathRequest var req dto.RecordDeathRequest
@@ -134,7 +134,7 @@ func (c *PigBatchController) RecordDeath(ctx *gin.Context) {
// @Param id path int true "猪批次ID" // @Param id path int true "猪批次ID"
// @Param body body dto.RecordCullRequest true "记录正常猪只淘汰请求信息" // @Param body body dto.RecordCullRequest true "记录正常猪只淘汰请求信息"
// @Success 200 {object} controller.Response "记录成功" // @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) { func (c *PigBatchController) RecordCull(ctx *gin.Context) {
const action = "记录正常猪只淘汰事件" const action = "记录正常猪只淘汰事件"
var req dto.RecordCullRequest var req dto.RecordCullRequest

View File

@@ -14,7 +14,7 @@ import (
// @Param id path int true "猪批次ID" // @Param id path int true "猪批次ID"
// @Param body body dto.SellPigsRequest true "卖猪请求信息" // @Param body body dto.SellPigsRequest true "卖猪请求信息"
// @Success 200 {object} controller.Response "卖猪成功" // @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) { func (c *PigBatchController) SellPigs(ctx *gin.Context) {
const action = "卖猪" const action = "卖猪"
var req dto.SellPigsRequest var req dto.SellPigsRequest
@@ -38,7 +38,7 @@ func (c *PigBatchController) SellPigs(ctx *gin.Context) {
// @Param id path int true "猪批次ID" // @Param id path int true "猪批次ID"
// @Param body body dto.BuyPigsRequest true "买猪请求信息" // @Param body body dto.BuyPigsRequest true "买猪请求信息"
// @Success 200 {object} controller.Response "买猪成功" // @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) { func (c *PigBatchController) BuyPigs(ctx *gin.Context) {
const action = "买猪" const action = "买猪"
var req dto.BuyPigsRequest var req dto.BuyPigsRequest

View File

@@ -16,7 +16,7 @@ import (
// @Param sourceBatchID path int true "源猪批次ID" // @Param sourceBatchID path int true "源猪批次ID"
// @Param body body dto.TransferPigsAcrossBatchesRequest true "跨群调栏请求信息" // @Param body body dto.TransferPigsAcrossBatchesRequest true "跨群调栏请求信息"
// @Success 200 {object} controller.Response "调栏成功" // @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) { func (c *PigBatchController) TransferPigsAcrossBatches(ctx *gin.Context) {
const action = "跨猪群调栏" const action = "跨猪群调栏"
var req dto.TransferPigsAcrossBatchesRequest var req dto.TransferPigsAcrossBatchesRequest
@@ -48,7 +48,7 @@ func (c *PigBatchController) TransferPigsAcrossBatches(ctx *gin.Context) {
// @Param id path int true "猪批次ID" // @Param id path int true "猪批次ID"
// @Param body body dto.TransferPigsWithinBatchRequest true "群内调栏请求信息" // @Param body body dto.TransferPigsWithinBatchRequest true "群内调栏请求信息"
// @Success 200 {object} controller.Response "调栏成功" // @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) { func (c *PigBatchController) TransferPigsWithinBatch(ctx *gin.Context) {
const action = "群内调栏" const action = "群内调栏"
var req dto.TransferPigsWithinBatchRequest var req dto.TransferPigsWithinBatchRequest