修复软删除和唯一索引同时存在的bug

This commit is contained in:
2025-11-20 17:37:02 +08:00
parent 1f3d3d8a7c
commit da934a9bbb
7 changed files with 80 additions and 8 deletions

View File

@@ -21,7 +21,7 @@ const (
// RawMaterial 代表一种原料的静态定义,是系统中的原料字典。
type RawMaterial struct {
Model
Name string `gorm:"size:100;unique;not null;comment:原料名称"`
Name string `gorm:"size:100;not null;comment:原料名称"`
Description string `gorm:"size:255;comment:描述"`
// RawMaterialNutrients 关联此原料的所有营养素含量信息
RawMaterialNutrients []RawMaterialNutrient `gorm:"foreignKey:RawMaterialID"`
@@ -36,7 +36,7 @@ func (RawMaterial) TableName() string {
// 约定:宏量营养素(粗蛋白等)单位为百分比(%),微量元素(氨基酸等)单位为毫克/千克(mg/kg)。
type Nutrient struct {
Model
Name string `gorm:"size:100;unique;not null;comment:营养素名称"`
Name string `gorm:"size:100;not null;comment:营养素名称"`
Description string `gorm:"size:255;comment:描述"`
// RawMaterialNutrients 记录营养在哪些原料中存在且比例是多少
RawMaterialNutrients []RawMaterialNutrient `gorm:"foreignKey:NutrientID"`