package entities import ( "time" "github.com/google/uuid" "gorm.io/gorm" ) type ProductOutletPrice struct { ID uuid.UUID `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"` ProductID uuid.UUID `gorm:"type:uuid;not null;index" json:"product_id"` OutletID uuid.UUID `gorm:"type:uuid;not null;index" json:"outlet_id"` Price float64 `gorm:"type:decimal(10,2);not null" json:"price"` CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"` UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"` Product Product `gorm:"foreignKey:ProductID" json:"product,omitempty"` Outlet Outlet `gorm:"foreignKey:OutletID" json:"outlet,omitempty"` } func (p *ProductOutletPrice) BeforeCreate(tx *gorm.DB) error { if p.ID == uuid.Nil { p.ID = uuid.New() } return nil } func (ProductOutletPrice) TableName() string { return "product_outlet_prices" }