feat(marketplace): add ProductPreview, ProductImage models and Product enrichment fields
This commit is contained in:
parent
e8ad5b5f4b
commit
8de3dcdc27
1 changed files with 41 additions and 0 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue