package ordersmodel import ( "github.com/qit-team/snow-core/db" "sync" "time" ) var ( once sync.Once m *OrdersModel ) // 实体 type Orders struct { Id string `xorm:"'id' UNSIGNED INT pk autoincr"` OrderNo string `xorm:"'order_no' varchar(50)"` UserId int `xorm:"'user_id' int(0)"` YouchuUserId int `xorm:"'YouChu_User_id' int(11)"` UserName string `xorm:"'user_name' varchar(11)"` Mobile string `xorm:"'mobile' varchar(13)"` ProductId int `xorm:"'product_id' int(0)"` ProductName string `xorm:"'product_name' varchar(50)"` Price string `xorm:"'price' decimal(10,2)"` ActivityId string `xorm:"'activity_id' UNSIGNED INT"` State string `xorm:"'state' UNSIGNED TINYINT"` VoucherId int `xorm:"'voucher_id' int(0)"` VoucherLink string `xorm:"'voucher_link' varchar(255)"` CreateTime time.Time `xorm:"'create_time' datetime"` UpdateTime time.Time `xorm:"'update_time' datetime"` ExchangeTime time.Time `xorm:"'exchange_time' datetime"` Deleted time.Time `xorm:"'Deleted' datetime"` } // 表名 func (m *Orders) TableName() string { return "Orders" } // 私有化,防止被外部new type OrdersModel struct { db.Model //组合基础Model,集成基础Model的属性和方法 } // 单例模式 func GetInstance() *OrdersModel { once.Do(func() { m = new(OrdersModel) //m.DiName = "" //设置数据库实例连接,默认db.SingletonMain }) return m }