Files
pig-farm-controller/internal/app/dto/pig_batch_dto.go

163 lines
9.9 KiB
Go
Raw Normal View History

2025-10-03 23:42:14 +08:00
package dto
import (
"time"
2025-10-04 00:47:27 +08:00
"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
2025-10-03 23:42:14 +08:00
)
// PigBatchCreateDTO 定义了创建猪批次的请求结构
type PigBatchCreateDTO struct {
2025-10-30 17:39:05 +08:00
BatchNumber string `json:"batch_number" validate:"required"` // 批次编号,必填
OriginType models.PigBatchOriginType `json:"origin_type" validate:"required"` // 批次来源,必填
StartDate time.Time `json:"start_date" validate:"required"` // 批次开始日期,必填
InitialCount int `json:"initial_count" validate:"required,min=1"` // 初始数量必填最小为1
Status models.PigBatchStatus `json:"status" validate:"required"` // 批次状态,必填
2025-10-03 23:42:14 +08:00
}
// PigBatchUpdateDTO 定义了更新猪批次的请求结构
type PigBatchUpdateDTO struct {
BatchNumber *string `json:"batch_number"` // 批次编号,可选
OriginType *models.PigBatchOriginType `json:"origin_type"` // 批次来源,可选
StartDate *time.Time `json:"start_date"` // 批次开始日期,可选
EndDate *time.Time `json:"end_date"` // 批次结束日期,可选
InitialCount *int `json:"initial_count"` // 初始数量,可选
Status *models.PigBatchStatus `json:"status"` // 批次状态,可选
}
// PigBatchQueryDTO 定义了查询猪批次的请求结构
type PigBatchQueryDTO struct {
2025-10-30 17:39:05 +08:00
IsActive *bool `json:"is_active" query:"is_active"` // 是否活跃可选用于URL查询参数
2025-10-03 23:42:14 +08:00
}
// PigBatchResponseDTO 定义了猪批次信息的响应结构
type PigBatchResponseDTO struct {
2025-10-31 18:14:12 +08:00
ID uint `json:"id"` // 批次ID
BatchNumber string `json:"batch_number"` // 批次编号
OriginType models.PigBatchOriginType `json:"origin_type"` // 批次来源
StartDate time.Time `json:"start_date"` // 批次开始日期
EndDate time.Time `json:"end_date"` // 批次结束日期
InitialCount int `json:"initial_count"` // 初始数量
Status models.PigBatchStatus `json:"status"` // 批次状态
IsActive bool `json:"is_active"` // 是否活跃
CurrentTotalQuantity int `json:"current_total_quantity"` // 当前总数
CurrentTotalPigsInPens int `json:"current_total_pigs_in_pens"` // 当前存栏总数
CreateTime time.Time `json:"create_time"` // 创建时间
UpdateTime time.Time `json:"update_time"` // 更新时间
2025-10-03 23:42:14 +08:00
}
2025-10-04 00:47:27 +08:00
2025-10-06 23:10:58 +08:00
// AssignEmptyPensToBatchRequest 用于为猪批次分配空栏的请求体
type AssignEmptyPensToBatchRequest struct {
2025-10-31 18:14:12 +08:00
PenIDs []uint `json:"pen_ids" validate:"required,min=1,dive" example:"1,2,3"` // 待分配的猪栏ID列表
2025-10-06 23:10:58 +08:00
}
// ReclassifyPenToNewBatchRequest 用于将猪栏划拨到新批次的请求体
type ReclassifyPenToNewBatchRequest struct {
2025-10-31 18:14:12 +08:00
ToBatchID uint `json:"to_batch_id" validate:"required"` // 目标猪批次ID
PenID uint `json:"pen_id" validate:"required"` // 待划拨的猪栏ID
Remarks string `json:"remarks"` // 备注
2025-10-06 23:10:58 +08:00
}
// RemoveEmptyPenFromBatchRequest 用于从猪批次移除空栏的请求体
type RemoveEmptyPenFromBatchRequest struct {
2025-10-31 18:14:12 +08:00
PenID uint `json:"pen_id" validate:"required"` // 待移除的猪栏ID
2025-10-06 23:10:58 +08:00
}
// MovePigsIntoPenRequest 用于将猪只从“虚拟库存”移入指定猪栏的请求体
type MovePigsIntoPenRequest struct {
2025-10-31 18:14:12 +08:00
ToPenID uint `json:"to_pen_id" validate:"required"` // 目标猪栏ID
2025-10-30 17:39:05 +08:00
Quantity int `json:"quantity" validate:"required,min=1"` // 移入猪只数量
Remarks string `json:"remarks"` // 备注
2025-10-04 00:47:27 +08:00
}
2025-10-06 23:22:47 +08:00
// SellPigsRequest 用于处理卖猪的请求体
type SellPigsRequest struct {
2025-10-31 18:14:12 +08:00
PenID uint `json:"pen_id" validate:"required"` // 猪栏ID
Quantity int `json:"quantity" validate:"required,min=1"` // 卖出猪只数量
2025-11-10 21:42:46 +08:00
UnitPrice float32 `json:"unit_price" validate:"required,min=0"` // 单价
TotalPrice float32 `json:"total_price" validate:"required,min=0"` // 总价
2025-10-31 18:14:12 +08:00
TraderName string `json:"trader_name" validate:"required"` // 交易方名称
TradeDate time.Time `json:"trade_date" validate:"required"` // 交易日期
Remarks string `json:"remarks"` // 备注
2025-10-06 23:22:47 +08:00
}
// BuyPigsRequest 用于处理买猪的请求体
type BuyPigsRequest struct {
2025-10-31 18:14:12 +08:00
PenID uint `json:"pen_id" validate:"required"` // 猪栏ID
Quantity int `json:"quantity" validate:"required,min=1"` // 买入猪只数量
2025-11-10 21:42:46 +08:00
UnitPrice float32 `json:"unit_price" validate:"required,min=0"` // 单价
TotalPrice float32 `json:"total_price" validate:"required,min=0"` // 总价
2025-10-31 18:14:12 +08:00
TraderName string `json:"trader_name" validate:"required"` // 交易方名称
TradeDate time.Time `json:"trade_date" validate:"required"` // 交易日期
Remarks string `json:"remarks"` // 备注
2025-10-06 23:22:47 +08:00
}
// TransferPigsAcrossBatchesRequest 用于跨猪群调栏的请求体
type TransferPigsAcrossBatchesRequest struct {
2025-10-31 18:14:12 +08:00
DestBatchID uint `json:"dest_batch_id" validate:"required"` // 目标猪批次ID
FromPenID uint `json:"from_pen_id" validate:"required"` // 源猪栏ID
ToPenID uint `json:"to_pen_id" validate:"required"` // 目标猪栏ID
2025-10-30 17:39:05 +08:00
Quantity uint `json:"quantity" validate:"required,min=1"` // 调栏猪只数量
Remarks string `json:"remarks"` // 备注
2025-10-06 23:22:47 +08:00
}
// TransferPigsWithinBatchRequest 用于群内调栏的请求体
type TransferPigsWithinBatchRequest struct {
2025-10-31 18:14:12 +08:00
FromPenID uint `json:"from_pen_id" validate:"required"` // 源猪栏ID
ToPenID uint `json:"to_pen_id" validate:"required"` // 目标猪栏ID
2025-10-30 17:39:05 +08:00
Quantity uint `json:"quantity" validate:"required,min=1"` // 调栏猪只数量
Remarks string `json:"remarks"` // 备注
2025-10-06 23:22:47 +08:00
}
// RecordSickPigsRequest 用于记录新增病猪事件的请求体
type RecordSickPigsRequest struct {
2025-10-31 18:14:12 +08:00
PenID uint `json:"pen_id" validate:"required"` // 猪栏ID
Quantity int `json:"quantity" validate:"required,min=1"` // 病猪数量
TreatmentLocation models.PigBatchSickPigTreatmentLocation `json:"treatment_location" validate:"required"` // 治疗地点
HappenedAt time.Time `json:"happened_at" validate:"required"` // 发生时间
Remarks string `json:"remarks"` // 备注
2025-10-06 23:22:47 +08:00
}
// RecordSickPigRecoveryRequest 用于记录病猪康复事件的请求体
type RecordSickPigRecoveryRequest struct {
2025-10-31 18:14:12 +08:00
PenID uint `json:"pen_id" validate:"required"` // 猪栏ID
Quantity int `json:"quantity" validate:"required,min=1"` // 康复猪数量
TreatmentLocation models.PigBatchSickPigTreatmentLocation `json:"treatment_location" validate:"required"` // 治疗地点
HappenedAt time.Time `json:"happened_at" validate:"required"` // 发生时间
Remarks string `json:"remarks"` // 备注
2025-10-06 23:22:47 +08:00
}
// RecordSickPigDeathRequest 用于记录病猪死亡事件的请求体
type RecordSickPigDeathRequest struct {
2025-10-31 18:14:12 +08:00
PenID uint `json:"pen_id" validate:"required"` // 猪栏ID
Quantity int `json:"quantity" validate:"required,min=1"` // 死亡猪数量
TreatmentLocation models.PigBatchSickPigTreatmentLocation `json:"treatment_location" validate:"required"` // 治疗地点
HappenedAt time.Time `json:"happened_at" validate:"required"` // 发生时间
Remarks string `json:"remarks"` // 备注
2025-10-06 23:22:47 +08:00
}
// RecordSickPigCullRequest 用于记录病猪淘汰事件的请求体
type RecordSickPigCullRequest struct {
2025-10-31 18:14:12 +08:00
PenID uint `json:"pen_id" validate:"required"` // 猪栏ID
Quantity int `json:"quantity" validate:"required,min=1"` // 淘汰猪数量
TreatmentLocation models.PigBatchSickPigTreatmentLocation `json:"treatment_location" validate:"required"` // 治疗地点
HappenedAt time.Time `json:"happened_at" validate:"required"` // 发生时间
Remarks string `json:"remarks"` // 备注
2025-10-06 23:22:47 +08:00
}
// RecordDeathRequest 用于记录正常猪只死亡事件的请求体
type RecordDeathRequest struct {
2025-10-31 18:14:12 +08:00
PenID uint `json:"pen_id" validate:"required"` // 猪栏ID
2025-10-30 17:39:05 +08:00
Quantity int `json:"quantity" validate:"required,min=1"` // 死亡猪数量
2025-10-31 18:14:12 +08:00
HappenedAt time.Time `json:"happened_at" validate:"required"` // 发生时间
2025-10-30 17:39:05 +08:00
Remarks string `json:"remarks"` // 备注
2025-10-06 23:22:47 +08:00
}
// RecordCullRequest 用于记录正常猪只淘汰事件的请求体
type RecordCullRequest struct {
2025-10-31 18:14:12 +08:00
PenID uint `json:"pen_id" validate:"required"` // 猪栏ID
2025-10-30 17:39:05 +08:00
Quantity int `json:"quantity" validate:"required,min=1"` // 淘汰猪数量
2025-10-31 18:14:12 +08:00
HappenedAt time.Time `json:"happened_at" validate:"required"` // 发生时间
2025-10-30 17:39:05 +08:00
Remarks string `json:"remarks"` // 备注
2025-10-06 23:22:47 +08:00
}