实现修改猪营养需求
This commit is contained in:
29
internal/infra/models/recipe.go
Normal file
29
internal/infra/models/recipe.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package models
|
||||
|
||||
// Recipe 配方模型
|
||||
type Recipe struct {
|
||||
Model
|
||||
Name string `gorm:"size:100;not null;comment:配方名称"`
|
||||
Description string `gorm:"size:255;comment:配方描述"`
|
||||
// RecipeIngredients 关联此配方的所有原料组成
|
||||
RecipeIngredients []RecipeIngredient `gorm:"foreignKey:RecipeID"`
|
||||
}
|
||||
|
||||
func (Recipe) TableName() string {
|
||||
return "recipes"
|
||||
}
|
||||
|
||||
// RecipeIngredient 配方原料组成模型
|
||||
type RecipeIngredient struct {
|
||||
Model
|
||||
RecipeID uint32 `gorm:"not null;comment:关联的配方ID"`
|
||||
Recipe Recipe `gorm:"foreignKey:RecipeID"`
|
||||
RawMaterialID uint32 `gorm:"not null;comment:关联的原料ID"`
|
||||
RawMaterial RawMaterial `gorm:"foreignKey:RawMaterialID"`
|
||||
// 重量百分比
|
||||
Percentage float32 `gorm:"not null;comment:原料在配方中的百分比 (0-1之间的小数, 例如0.15代表15%)"`
|
||||
}
|
||||
|
||||
func (RecipeIngredient) TableName() string {
|
||||
return "recipe_ingredients"
|
||||
}
|
||||
Reference in New Issue
Block a user