package recipes import ( "time" "rmser/internal/domain/catalog" "github.com/google/uuid" "github.com/shopspring/decimal" ) // Recipe - Технологическая карта type Recipe struct { ID uuid.UUID `gorm:"type:uuid;primary_key;"` ProductID uuid.UUID `gorm:"type:uuid;not null;index"` DateFrom time.Time `gorm:"index"` DateTo *time.Time Product catalog.Product `gorm:"foreignKey:ProductID"` Items []RecipeItem `gorm:"foreignKey:RecipeID;constraint:OnDelete:CASCADE"` } // RecipeItem - Ингредиент type RecipeItem struct { ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()"` RecipeID uuid.UUID `gorm:"type:uuid;not null;index"` ProductID uuid.UUID `gorm:"type:uuid;not null;index"` AmountIn decimal.Decimal `gorm:"type:numeric(19,4);not null"` AmountOut decimal.Decimal `gorm:"type:numeric(19,4);not null"` Product catalog.Product `gorm:"foreignKey:ProductID"` } type Repository interface { SaveRecipes(recipes []Recipe) error }