package models import ( "gorm.io/gorm" ) /* 猪场固定资产相关模型 */ // PigHouse 定义了猪舍,是猪栏的集合 type PigHouse struct { gorm.Model Name string `gorm:"size:100;not null;unique;comment:猪舍名称, 如 '育肥舍A栋'"` Description string `gorm:"size:255;comment:描述信息"` Pens []Pen `gorm:"foreignKey:HouseID"` // 一个猪舍包含多个猪栏 } // PenStatus 定义了猪栏的当前状态 type PenStatus string const ( PenStatusEmpty PenStatus = "空闲" PenStatusOccupied PenStatus = "占用" PenStatusSickPen PenStatus = "病猪栏" PenStatusRecovering PenStatus = "康复栏" PenStatusCleaning PenStatus = "清洗消毒" PenStatusUnderMaint PenStatus = "维修中" ) // Pen 是猪栏的物理实体模型, 是所有空间相关数据的“锚点” type Pen struct { gorm.Model PenNumber string `gorm:"not null;comment:猪栏的唯一编号, 如 A-01"` HouseID uint `gorm:"index;comment:所属猪舍ID"` PigBatchID uint `gorm:"index;comment:关联的猪批次ID"` Capacity int `gorm:"not null;comment:设计容量 (头)"` Status PenStatus `gorm:"not null;index;comment:猪栏当前状态"` }