迁移配置文件, 实现从json文件中读取原材料营养预设值, 并自动写入数据库

This commit is contained in:
2025-11-19 19:31:51 +08:00
parent a1be06854f
commit a74ab4e5e7
9 changed files with 1991 additions and 186 deletions

View File

@@ -18,14 +18,6 @@ const (
StockLogSourceFermentEnd StockLogSourceType = "发酵入库" // 发酵料产出,作为新原料计入库存
)
// NutrientType 定义了营养素的分类,用于配方优化和成本控制。
type NutrientType string
const (
PositiveNutrient NutrientType = "正面营养" // 希望在配方中最大化的营养素,如蛋白质、能量
NegativeNutrient NutrientType = "负面营养" // 需要控制上限的营养素,如粗纤维、霉菌毒素
)
// RawMaterial 代表一种原料的静态定义,是系统中的原料字典。
type RawMaterial struct {
Model
@@ -45,9 +37,8 @@ func (RawMaterial) TableName() string {
// 约定:宏量营养素(粗蛋白等)单位为百分比(%),微量元素(氨基酸等)单位为毫克/千克(mg/kg)。
type Nutrient struct {
Model
Name string `gorm:"size:100;unique;not null;comment:营养素名称"`
Type NutrientType `gorm:"size:50;not null;comment:营养素类型 (正面营养/负面营养)"`
Description string `gorm:"size:255;comment:描述"`
Name string `gorm:"size:100;unique;not null;comment:营养素名称"`
Description string `gorm:"size:255;comment:描述"`
}
func (Nutrient) TableName() string {