package productsmodel

import (
	"github.com/qit-team/snow-core/db"
	"sync"
)

var (
	once sync.Once
	m    *ProductsModel
)

// 实体
type Products struct {
	Id              int    `xorm:"'Id' int(0)"`
	Productname     string `xorm:"'ProductName' varchar(255)"`
	Producttype     int    `xorm:"'ProductType' int(0)"`
	Packetrule      int    `xorm:"'PacketRule' TINYINT"`
	Productkind     int    `xorm:"'ProductKind' TINYINT"`
	Amount          string `xorm:"'Amount' decimal(9,2)"`
	Coupontype      int    `xorm:"'CouponType' TINYINT"`
	Issuperposition int    `xorm:"'IsSuperposition' TINYINT"`
	Templateid      int    `xorm:"'TemplateId' int(0)"`
	Status          int    `xorm:"'Status' TINYINT"`
	Isneedbill      int    `xorm:"'IsNeedBill' TINYINT"`
	//Createtime          time.Time `xorm:"'CreateTime' datetime"`
	Supplierproductid   int64  `xorm:"'SupplierProductId' bigint(0)"`
	Supplierproductname string `xorm:"'SupplierProductName' varchar(255)"`
}

// 表名
func (m *Products) TableName() string {
	return "Products"
}

// 私有化,防止被外部new
type ProductsModel struct {
	db.Model //组合基础Model,集成基础Model的属性和方法
}

// 单例模式
func GetInstance() *ProductsModel {
	once.Do(func() {
		m = new(ProductsModel)
		//m.DiName = "" //设置数据库实例连接,默认db.SingletonMain
	})
	return m
}