157 lines
		
	
	
		
			6.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			157 lines
		
	
	
		
			6.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package management
 | 
						|
 | 
						|
import (
 | 
						|
	"git.huangwc.com/pig/pig-farm-controller/internal/app/dto"
 | 
						|
	"github.com/gin-gonic/gin"
 | 
						|
)
 | 
						|
 | 
						|
// RecordSickPigs godoc
 | 
						|
// @Summary      记录新增病猪事件
 | 
						|
// @Description  记录猪批次中新增病猪的数量、治疗地点和发生时间
 | 
						|
// @Tags         猪群管理
 | 
						|
// @Security     BearerAuth
 | 
						|
// @Accept       json
 | 
						|
// @Produce      json
 | 
						|
// @Param        id path int true "猪批次ID"
 | 
						|
// @Param        body body dto.RecordSickPigsRequest true "记录病猪请求信息"
 | 
						|
// @Success      200 {object} controller.Response "记录成功"
 | 
						|
// @Router       /api/v1/pig-batches/record-sick-pigs/{id} [post]
 | 
						|
func (c *PigBatchController) RecordSickPigs(ctx *gin.Context) {
 | 
						|
	const action = "记录新增病猪事件"
 | 
						|
	var req dto.RecordSickPigsRequest
 | 
						|
 | 
						|
	handleAPIRequest(
 | 
						|
		c, ctx, action, &req,
 | 
						|
		func(ctx *gin.Context, operatorID uint, primaryID uint, req *dto.RecordSickPigsRequest) error {
 | 
						|
			return c.service.RecordSickPigs(operatorID, primaryID, req.PenID, req.Quantity, req.TreatmentLocation, req.HappenedAt, req.Remarks)
 | 
						|
		},
 | 
						|
		"记录成功",
 | 
						|
		nil, // 默认从 ":id" 路径参数提取ID
 | 
						|
	)
 | 
						|
}
 | 
						|
 | 
						|
// RecordSickPigRecovery godoc
 | 
						|
// @Summary      记录病猪康复事件
 | 
						|
// @Description  记录猪批次中病猪康复的数量、治疗地点和发生时间
 | 
						|
// @Tags         猪群管理
 | 
						|
// @Security     BearerAuth
 | 
						|
// @Accept       json
 | 
						|
// @Produce      json
 | 
						|
// @Param        id path int true "猪批次ID"
 | 
						|
// @Param        body body dto.RecordSickPigRecoveryRequest true "记录病猪康复请求信息"
 | 
						|
// @Success      200 {object} controller.Response "记录成功"
 | 
						|
// @Router       /api/v1/pig-batches/record-sick-pig-recovery/{id} [post]
 | 
						|
func (c *PigBatchController) RecordSickPigRecovery(ctx *gin.Context) {
 | 
						|
	const action = "记录病猪康复事件"
 | 
						|
	var req dto.RecordSickPigRecoveryRequest
 | 
						|
 | 
						|
	handleAPIRequest(
 | 
						|
		c, ctx, action, &req,
 | 
						|
		func(ctx *gin.Context, operatorID uint, primaryID uint, req *dto.RecordSickPigRecoveryRequest) error {
 | 
						|
			return c.service.RecordSickPigRecovery(operatorID, primaryID, req.PenID, req.Quantity, req.TreatmentLocation, req.HappenedAt, req.Remarks)
 | 
						|
		},
 | 
						|
		"记录成功",
 | 
						|
		nil, // 默认从 ":id" 路径参数提取ID
 | 
						|
	)
 | 
						|
}
 | 
						|
 | 
						|
// RecordSickPigDeath godoc
 | 
						|
// @Summary      记录病猪死亡事件
 | 
						|
// @Description  记录猪批次中病猪死亡的数量、治疗地点和发生时间
 | 
						|
// @Tags         猪群管理
 | 
						|
// @Security     BearerAuth
 | 
						|
// @Accept       json
 | 
						|
// @Produce      json
 | 
						|
// @Param        id path int true "猪批次ID"
 | 
						|
// @Param        body body dto.RecordSickPigDeathRequest true "记录病猪死亡请求信息"
 | 
						|
// @Success      200 {object} controller.Response "记录成功"
 | 
						|
// @Router       /api/v1/pig-batches/record-sick-pig-death/{id} [post]
 | 
						|
func (c *PigBatchController) RecordSickPigDeath(ctx *gin.Context) {
 | 
						|
	const action = "记录病猪死亡事件"
 | 
						|
	var req dto.RecordSickPigDeathRequest
 | 
						|
 | 
						|
	handleAPIRequest(
 | 
						|
		c, ctx, action, &req,
 | 
						|
		func(ctx *gin.Context, operatorID uint, primaryID uint, req *dto.RecordSickPigDeathRequest) error {
 | 
						|
			return c.service.RecordSickPigDeath(operatorID, primaryID, req.PenID, req.Quantity, req.TreatmentLocation, req.HappenedAt, req.Remarks)
 | 
						|
		},
 | 
						|
		"记录成功",
 | 
						|
		nil, // 默认从 ":id" 路径参数提取ID
 | 
						|
	)
 | 
						|
}
 | 
						|
 | 
						|
// RecordSickPigCull godoc
 | 
						|
// @Summary      记录病猪淘汰事件
 | 
						|
// @Description  记录猪批次中病猪淘汰的数量、治疗地点和发生时间
 | 
						|
// @Tags         猪群管理
 | 
						|
// @Security     BearerAuth
 | 
						|
// @Accept       json
 | 
						|
// @Produce      json
 | 
						|
// @Param        id path int true "猪批次ID"
 | 
						|
// @Param        body body dto.RecordSickPigCullRequest true "记录病猪淘汰请求信息"
 | 
						|
// @Success      200 {object} controller.Response "记录成功"
 | 
						|
// @Router       /api/v1/pig-batches/record-sick-pig-cull/{id} [post]
 | 
						|
func (c *PigBatchController) RecordSickPigCull(ctx *gin.Context) {
 | 
						|
	const action = "记录病猪淘汰事件"
 | 
						|
	var req dto.RecordSickPigCullRequest
 | 
						|
 | 
						|
	handleAPIRequest(
 | 
						|
		c, ctx, action, &req,
 | 
						|
		func(ctx *gin.Context, operatorID uint, primaryID uint, req *dto.RecordSickPigCullRequest) error {
 | 
						|
			return c.service.RecordSickPigCull(operatorID, primaryID, req.PenID, req.Quantity, req.TreatmentLocation, req.HappenedAt, req.Remarks)
 | 
						|
		},
 | 
						|
		"记录成功",
 | 
						|
		nil, // 默认从 ":id" 路径参数提取ID
 | 
						|
	)
 | 
						|
}
 | 
						|
 | 
						|
// RecordDeath godoc
 | 
						|
// @Summary      记录正常猪只死亡事件
 | 
						|
// @Description  记录猪批次中正常猪只死亡的数量和发生时间
 | 
						|
// @Tags         猪群管理
 | 
						|
// @Security     BearerAuth
 | 
						|
// @Accept       json
 | 
						|
// @Produce      json
 | 
						|
// @Param        id path int true "猪批次ID"
 | 
						|
// @Param        body body dto.RecordDeathRequest true "记录正常猪只死亡请求信息"
 | 
						|
// @Success      200 {object} controller.Response "记录成功"
 | 
						|
// @Router       /api/v1/pig-batches/record-death/{id} [post]
 | 
						|
func (c *PigBatchController) RecordDeath(ctx *gin.Context) {
 | 
						|
	const action = "记录正常猪只死亡事件"
 | 
						|
	var req dto.RecordDeathRequest
 | 
						|
 | 
						|
	handleAPIRequest(
 | 
						|
		c, ctx, action, &req,
 | 
						|
		func(ctx *gin.Context, operatorID uint, primaryID uint, req *dto.RecordDeathRequest) error {
 | 
						|
			return c.service.RecordDeath(operatorID, primaryID, req.PenID, req.Quantity, req.HappenedAt, req.Remarks)
 | 
						|
		},
 | 
						|
		"记录成功",
 | 
						|
		nil, // 默认从 ":id" 路径参数提取ID
 | 
						|
	)
 | 
						|
}
 | 
						|
 | 
						|
// RecordCull godoc
 | 
						|
// @Summary      记录正常猪只淘汰事件
 | 
						|
// @Description  记录猪批次中正常猪只淘汰的数量和发生时间
 | 
						|
// @Tags         猪群管理
 | 
						|
// @Security     BearerAuth
 | 
						|
// @Accept       json
 | 
						|
// @Produce      json
 | 
						|
// @Param        id path int true "猪批次ID"
 | 
						|
// @Param        body body dto.RecordCullRequest true "记录正常猪只淘汰请求信息"
 | 
						|
// @Success      200 {object} controller.Response "记录成功"
 | 
						|
// @Router       /api/v1/pig-batches/record-cull/{id} [post]
 | 
						|
func (c *PigBatchController) RecordCull(ctx *gin.Context) {
 | 
						|
	const action = "记录正常猪只淘汰事件"
 | 
						|
	var req dto.RecordCullRequest
 | 
						|
 | 
						|
	handleAPIRequest(
 | 
						|
		c, ctx, action, &req,
 | 
						|
		func(ctx *gin.Context, operatorID uint, primaryID uint, req *dto.RecordCullRequest) error {
 | 
						|
			return c.service.RecordCull(operatorID, primaryID, req.PenID, req.Quantity, req.HappenedAt, req.Remarks)
 | 
						|
		},
 | 
						|
		"记录成功",
 | 
						|
		nil, // 默认从 ":id" 路径参数提取ID
 | 
						|
	)
 | 
						|
}
 |