45 lines
1023 B
Go
45 lines
1023 B
Go
package merchantmodel
|
||
|
||
import (
|
||
"github.com/qit-team/snow-core/db"
|
||
"sync"
|
||
"time"
|
||
)
|
||
|
||
var (
|
||
once sync.Once
|
||
m *MerchantModel
|
||
)
|
||
|
||
// 实体
|
||
type Merchant struct {
|
||
Id int64
|
||
Name string `xorm:"'name' varchar(128)"`
|
||
Contact string `xorm:"'contact' varchar(128)"`
|
||
Phone string `xorm:"'phone' varchar(11)"`
|
||
Remark string `xorm:"'remark' varchar(1024)"`
|
||
CreateTime time.Time `xorm:"'create_time' datetime created"`
|
||
UpdateTime time.Time `xorm:"'update_time' timestamp updated"`
|
||
DeleteTime time.Time `xorm:"'delete_time' timestamp deleted"`
|
||
Creator int `xorm:"'creator' int(11)"`
|
||
}
|
||
|
||
// 表名
|
||
func (m *Merchant) TableName() string {
|
||
return "merchant"
|
||
}
|
||
|
||
// 私有化,防止被外部new
|
||
type MerchantModel struct {
|
||
db.Model //组合基础Model,集成基础Model的属性和方法
|
||
}
|
||
|
||
// 单例模式
|
||
func GetInstance() *MerchantModel {
|
||
once.Do(func() {
|
||
m = new(MerchantModel)
|
||
//m.DiName = "" //设置数据库实例连接,默认db.SingletonMain
|
||
})
|
||
return m
|
||
}
|