package models

/*
	猪场固定资产相关模型
*/

// PigHouse 定义了猪舍，是猪栏的集合
type PigHouse struct {
	Model
	Name        string `gorm:"size:100;not null;comment:猪舍名称, 如 '育肥舍A栋'"`
	Description string `gorm:"size:255;comment:描述信息"`
	Pens        []Pen  `gorm:"foreignKey:HouseID"` // 一个猪舍包含多个猪栏
}

func (ph PigHouse) TableName() string {
	return "pig_houses"
}

// PenStatus 定义了猪栏的当前状态
type PenStatus string

const (
	PenStatusEmpty      PenStatus = "空闲"
	PenStatusOccupied   PenStatus = "使用中"
	PenStatusSickPen    PenStatus = "病猪栏"
	PenStatusRecovering PenStatus = "康复栏"
	PenStatusCleaning   PenStatus = "清洗消毒"
	PenStatusUnderMaint PenStatus = "维修中"
)

// Pen 是猪栏的物理实体模型, 是所有空间相关数据的“锚点”
type Pen struct {
	Model
	PenNumber  string    `gorm:"not null;comment:猪栏的唯一编号, 如 A-01"`
	HouseID    uint32    `gorm:"index;comment:所属猪舍ID"`
	PigBatchID *uint32   `gorm:"index;comment:关联的猪批次ID"`
	Capacity   int       `gorm:"not null;comment:设计容量 (头)"`
	Status     PenStatus `gorm:"not null;index;comment:猪栏当前状态"`
}

func (p Pen) TableName() string {
	return "pens"
}
