mirror of
https://github.com/serty2005/rmser.git
synced 2026-02-04 19:02:33 -06:00
start rmser
This commit is contained in:
36
internal/domain/recipes/entity.go
Normal file
36
internal/domain/recipes/entity.go
Normal file
@@ -0,0 +1,36 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user