Files
pig-farm-controller/internal/infra/models/pig.go

49 lines
2.3 KiB
Go

package models
// PigBreed 猪品种模型
type PigBreed struct {
Model
Name string `gorm:"size:50;not null;comment:品种名称"`
Description string `gorm:"type:text" json:"description"` // 其他描述
ParentInfo string `gorm:"type:text" json:"parent_info"` // 父母信息
AppearanceFeatures string `gorm:"type:text" json:"appearance_features"` // 外貌特征
BreedAdvantages string `gorm:"type:text" json:"breed_advantages"` // 品种优点
BreedDisadvantages string `gorm:"type:text" json:"breed_disadvantages"` // 品种缺点
}
func (PigBreed) TableName() string {
return "pig_breeds"
}
// PigAgeStage 猪年龄阶段模型
type PigAgeStage struct {
Model
Name string `gorm:"size:50;not null;comment:年龄阶段名称 (如: 仔猪, 生长猪, 育肥猪)"`
Description string `gorm:"size:255;comment:阶段描述"`
}
func (PigAgeStage) TableName() string {
return "pig_age_stages"
}
// PigType 猪类型模型,代表特定品种和年龄阶段的组合
type PigType struct {
Model
BreedID uint32 `gorm:"not null;index;comment:关联的猪品种ID"`
Breed PigBreed `gorm:"foreignKey:BreedID"`
AgeStageID uint32 `gorm:"not null;index;comment:关联的猪年龄阶段ID"`
AgeStage PigAgeStage `gorm:"foreignKey:AgeStageID"`
Description string `gorm:"size:255;comment:该猪类型的描述或特点"`
DailyFeedIntake float32 `gorm:"comment:理论日均食量 (g/天)"`
DailyGainWeight float32 `gorm:"comment:理论日增重 (g/天)"`
MinDays uint32 `gorm:"comment:该猪类型在该年龄阶段的最小日龄"`
MaxDays uint32 `gorm:"comment:该猪类型在该年龄阶段的最大日龄"`
MinWeight float32 `gorm:"comment:该猪类型在该年龄阶段的最小体重 (g)"`
MaxWeight float32 `gorm:"comment:该猪类型在该年龄阶段的最大体重 (g)"`
PigNutrientRequirements []PigNutrientRequirement `gorm:"foreignKey:PigTypeID"`
}
func (PigType) TableName() string {
return "pig_types"
}