89 lines
3.6 KiB
Go
89 lines
3.6 KiB
Go
package gorm_models
|
|
|
|
import "time"
|
|
|
|
type Product struct {
|
|
ID uint `gorm:"primary_key"`
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
Sku string
|
|
Type string
|
|
ParentID uint `sql:"DEFAULT:NULL"`
|
|
AttributeFamilyID uint
|
|
AttributeFamily AttributeFamily
|
|
BrandID uint `sql:"DEFAULT:NULL"`
|
|
Brand Brand
|
|
Images []ProductImage
|
|
Categories []Category `gorm:"many2many:product_categories;"`
|
|
AttributeValues []ProductAttributeValue
|
|
SuperAttributes []Attribute `gorm:"many2many:product_super_attributes;"`
|
|
}
|
|
|
|
type ProductFlat struct {
|
|
ID uint `gorm:"primary_key"`
|
|
Sku string
|
|
ProductNumber string `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
Name string `sql:"DEFAULT:''" gorm:"default:''"`
|
|
Weight float64 `sql:"DEFAULT:NULL" gorm:"type:decimal(12,4);default:null"`
|
|
Status bool `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
Source string `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
VisibleIndividually bool `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
Price float64 `gorm:"type:decimal(12,4)"`
|
|
MinPrice float64 `gorm:"type:decimal(12,4)"`
|
|
MaxPrice float64 `gorm:"type:decimal(12,4)"`
|
|
SpecialPrice float64 `gorm:"type:decimal(12,4)"`
|
|
UrlKey string `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
ShortDescription string `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
Description string `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
FavoritesCount uint `sql:"DEFAULT:NULL" gorm:"default:null;column:favoritesCount"`
|
|
CreatedAt time.Time `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
UpdatedAt time.Time `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
ProductID uint
|
|
Product Product
|
|
Channel string `sql:"DEFAULT:default" gorm:"default:default"`
|
|
Locale string `sql:"DEFAULT:tm" gorm:"default:tm"`
|
|
ParentID *uint `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
Variants []ProductFlat `gorm:"foreignKey:ParentID"`
|
|
Color int `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
ColorLabel string `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
Size int `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
SizeLabel string `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
MetaTitle string `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
MetaKeywords string `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
BrandID uint `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
Brand Brand
|
|
}
|
|
|
|
type ProductImage struct {
|
|
ID uint `gorm:"primary_key"`
|
|
Type string
|
|
Path string
|
|
ProductID uint
|
|
}
|
|
|
|
type ProductAttributeValue struct {
|
|
ID uint `gorm:"primary_key"`
|
|
Locale string `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
Channel string `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
ProductID uint
|
|
AttributeID uint
|
|
TextValue string `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
BooleanValue bool `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
IntegerValue int `sql:"DEFAULT:NULL" gorm:"default:null"`
|
|
FloatValue float64 `sql:"DEFAULT:NULL" gorm:"type:decimal(12,4);default:null"`
|
|
}
|
|
|
|
type ProductSuperAttribute struct {
|
|
ProductID uint
|
|
AttributeID uint
|
|
}
|
|
|
|
type Tabler interface {
|
|
TableName() string
|
|
}
|
|
|
|
// TableName overrides the table name used by User to `profiles`
|
|
func (ProductFlat) TableName() string {
|
|
return "product_flat"
|
|
}
|