package models

import "time"

type AstromallProduct struct {
	ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
	Name string `gorm:"column:name;type:varchar(255);not null" json:"name"`
	Features string `gorm:"column:features;type:text;not null" json:"features"`
	ProductImage string `gorm:"column:productImage;type:varchar(255);not null" json:"productImage"`
	ProductCategoryID uint `gorm:"column:productCategoryId;not null;index" json:"productCategoryId"`
	Amount float64 `gorm:"column:sellingPrice;type:double;not null" json:"amount"`
	Description *string `gorm:"column:description;type:varchar(255)" json:"description"`
	ShortDescription  string    `gorm:"column:features" json:"shortDescription"`
	Price             float64   `gorm:"column:price" json:"price"`
	SellingPrice      float64   `gorm:"column:sellingPrice" json:"sellingPrice"`
	Quantity          int       `gorm:"column:quantity" json:"quantity"`
	IsActive bool `gorm:"column:isActive;default:true" json:"isActive"`
	IsDelete bool `gorm:"column:isDelete;default:false" json:"isDelete"`
	CreatedAt *time.Time `gorm:"column:created_at" json:"created_at"`
	UpdatedAt *time.Time `gorm:"column:updated_at" json:"updated_at"`
	CreatedBy int `gorm:"column:createdBy;not null" json:"createdBy"`
	ModifiedBy int `gorm:"column:modifiedBy;not null" json:"modifiedBy"`
	// Relations
	ProductCategory ProductCategory `gorm:"foreignKey:ProductCategoryID;references:ID" json:"productCategory"`
	Attributes []ProductAttribute `gorm:"foreignKey:ProductID" json:"attributes,omitempty"`
}

func (AstromallProduct) TableName() string {
	return "astromall_products"
}