定义病猪用药两个repo

This commit is contained in:
2025-10-06 15:26:44 +08:00
parent 91e18c432c
commit 1b026d6106
6 changed files with 61 additions and 1229 deletions

View File

@@ -27,20 +27,22 @@ const (
SickPigReasonTypeOther PigBatchSickPigReasonType = "其他" // 其他原因
)
// PigBatchSickPigLog 记录了猪批次中病猪数量的变化日志
type PigBatchSickPigLog struct {
// PigSickLog 记录了猪批次中病猪数量的变化日志
type PigSickLog struct {
gorm.Model
PigBatchID uint `gorm:"primaryKey;comment:关联的猪批次ID"`
PenID uint `gorm:"not null;index;comment:所在猪圈ID"`
PigIDs string `gorm:"size:500;comment:涉及的猪只ID列表逗号分隔"`
ChangeCount int `gorm:"not null;comment:变化数量, 正数表示新增, 负数表示移除"`
Reason PigBatchSickPigReasonType `gorm:"size:20;not null;comment:变化原因 (如: 患病, 康复, 死亡, 转入, 转出, 其他)"`
BeforeCount int `gorm:"comment:变化前的数量"`
AfterCount int `gorm:"comment:变化后的数量"`
Remarks string `gorm:"size:255;comment:备注"`
TreatmentLocation PigBatchSickPigTreatmentLocation `gorm:"size:50;comment:治疗地点"`
OperatorID uint `gorm:"comment:操作员ID"`
HappenedAt time.Time `gorm:"primaryKey;comment:事件发生时间"`
}
func (PigBatchSickPigLog) TableName() string {
return "pig_batch_sick_pig_logs"
func (PigSickLog) TableName() string {
return "pig_sick_logs"
}