package models

import "time"

type UserOrder struct {
	ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
	UserID uint `gorm:"column:userId;not null;index" json:"userId"`
	OrderAddressID uint `gorm:"column:orderAddressId;not null;index" json:"orderAddressId"`
	AstromallProductID uint `gorm:"column:astromallProductId;not null;index" json:"astromallProductId"`
	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" json:"createdBy"`
	ModifiedBy int `gorm:"column:modifiedBy" json:"modifiedBy"`
	// Relations
	User             User             `gorm:"foreignKey:UserID;references:ID" json:"user"`
	OrderAddress     OrderAddress     `gorm:"foreignKey:OrderAddressID;references:ID" json:"order_address"`
	AstromallProduct AstromallProduct `gorm:"foreignKey:AstromallProductID;references:ID" json:"astromall_product"`
}

func (UserOrder) TableName() string {
	return "user_orders"
}