定义猪的模型和营养需求模型
This commit is contained in:
43
internal/infra/models/pig.go
Normal file
43
internal/infra/models/pig.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package models
|
||||
|
||||
// PigBreed 猪品种模型
|
||||
type PigBreed struct {
|
||||
Model
|
||||
Name string `gorm:"size:50;not null;comment:品种名称"`
|
||||
Description string `gorm:"size:255;comment:品种描述"`
|
||||
}
|
||||
|
||||
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)"`
|
||||
}
|
||||
|
||||
func (PigType) TableName() string {
|
||||
return "pig_types"
|
||||
}
|
||||
Reference in New Issue
Block a user