定义猪的模型和营养需求模型

This commit is contained in:
2025-11-20 14:38:36 +08:00
parent c697e668e3
commit 6ca101727a
6 changed files with 121 additions and 4 deletions

View File

@@ -0,0 +1,16 @@
package models
// PigNutrientRequirement 猪营养需求模型
type PigNutrientRequirement struct {
Model
PigTypeID uint32 `gorm:"not null;index;comment:关联的猪类型ID"`
PigType PigType `gorm:"foreignKey:PigTypeID"`
NutrientID uint32 `gorm:"not null;index;comment:关联的营养素ID"`
Nutrient Nutrient `gorm:"foreignKey:NutrientID"`
MinRequirement float32 `gorm:"not null;comment:最低营养需求量"`
MaxRequirement float32 `gorm:"not null;comment:最高营养需求量"`
}
func (PigNutrientRequirement) TableName() string {
return "pig_nutrient_requirements"
}