package models import "time" type Product struct { ID int `json:"id" gorm:"primaryKey;autoIncrement"` Name string `json:"name" gorm:"column:name" binding:"required"` Category string `json:"category" gorm:"column:category" binding:"required"` Description string `json:"description" gorm:"column:description"` Stock float64 `json:"stock" gorm:"column:stock"` Unit string `json:"unit" gorm:"column:unit"` ComingSoon bool `json:"coming_soon" gorm:"column:coming_soon;default:false"` Prices []ProductPrice `json:"prices" gorm:"foreignKey:ProductID"` Media []Media `json:"media,omitempty" gorm:"foreignKey:ProductID"` CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"` UpdatedAt time.Time `json:"updated_at" gorm:"autoUpdateTime"` } func (Product) TableName() string { return "products" } type ProductPrice struct { ID int `json:"id" gorm:"primaryKey;autoIncrement"` ProductID int `json:"product_id" gorm:"column:product_id;index"` Quantity float64 `json:"quantity" gorm:"column:quantity" binding:"required"` Price float64 `json:"price" gorm:"column:price" binding:"required"` CreatedAt time.Time `json:"created_at" gorm:"autoCreateTime"` ActivePrice bool `json:"active_price" gorm:"column:active_price;default:true"` } func (ProductPrice) TableName() string { return "product_prices" } type StockInfo struct { ProductID int `json:"product_id"` ProductName string `json:"product_name"` Category string `json:"category"` Quantity float64 `json:"quantity"` Reserved float64 `json:"reserved"` Available float64 `json:"available"` LastUpdated string `json:"last_updated"` } // ============================================ // MÉTHODES POUR L'INTERFACE ProductInterface // ============================================ func (p *Product) GetName() string { return p.Name } func (p *Product) GetCategory() string { return p.Category } func (p *Product) GetDescription() string { return p.Description } func (p *Product) GetStock() float64 { return p.Stock } func (p *Product) GetUnit() string { return p.Unit } func (p *Product) GetPrices() []ProductPrice { return p.Prices } func (p *Product) SetID(id int) { p.ID = id } func (p *Product) SetCreatedAt(t time.Time) { p.CreatedAt = t } func (p *Product) SetUpdatedAt(t time.Time) { p.UpdatedAt = t }