mirror of
https://github.com/serty2005/rmser.git
synced 2026-02-05 03:12:34 -06:00
37 lines
1.0 KiB
Go
37 lines
1.0 KiB
Go
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
|
|
}
|