diff --git a/veza-backend-api/internal/core/marketplace/models.go b/veza-backend-api/internal/core/marketplace/models.go index 18c95f2a8..5244f8816 100644 --- a/veza-backend-api/internal/core/marketplace/models.go +++ b/veza-backend-api/internal/core/marketplace/models.go @@ -40,11 +40,52 @@ type Product struct { TrackID *uuid.UUID `gorm:"type:uuid" json:"track_id,omitempty"` LicenseType LicenseType `gorm:"size:50" json:"license_type,omitempty"` + // v0.401 M1: Métadonnées musicales et catégorie + BPM *int `gorm:"column:bpm" json:"bpm,omitempty"` + MusicalKey string `gorm:"column:musical_key;size:10" json:"musical_key,omitempty"` + Category string `gorm:"column:category;size:50" json:"category,omitempty"` // sample, beat, preset, pack + + // Relations + Previews []ProductPreview `gorm:"foreignKey:ProductID" json:"previews,omitempty"` + Images []ProductImage `gorm:"foreignKey:ProductID" json:"images,omitempty"` + CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"` UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"` DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` } +// ProductPreview représente un fichier audio de démo pour un produit +type ProductPreview struct { + ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"` + ProductID uuid.UUID `gorm:"type:uuid;not null" json:"product_id"` + FilePath string `gorm:"not null;size:512" json:"file_path"` + DurationSec *int `gorm:"column:duration_sec" json:"duration_sec,omitempty"` + CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"` +} + +func (pp *ProductPreview) BeforeCreate(tx *gorm.DB) (err error) { + if pp.ID == uuid.Nil { + pp.ID = uuid.New() + } + return +} + +// ProductImage représente une image associée à un produit +type ProductImage struct { + ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"` + ProductID uuid.UUID `gorm:"type:uuid;not null" json:"product_id"` + URL string `gorm:"not null;size:512" json:"url"` + SortOrder int `gorm:"default:0" json:"sort_order"` + CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"` +} + +func (pi *ProductImage) BeforeCreate(tx *gorm.DB) (err error) { + if pi.ID == uuid.Nil { + pi.ID = uuid.New() + } + return +} + func (p *Product) BeforeCreate(tx *gorm.DB) (err error) { if p.ID == uuid.Nil { p.ID = uuid.New()