44 lines
946 B
Go
44 lines
946 B
Go
package brandmodel
|
||
|
||
import (
|
||
"github.com/qit-team/snow-core/db"
|
||
"sync"
|
||
"time"
|
||
)
|
||
|
||
var (
|
||
once sync.Once
|
||
m *BrandModel
|
||
)
|
||
|
||
// 实体
|
||
type Brand struct {
|
||
Id int `xorm:"'id' int(10) pk autoincr"`
|
||
Logo string `xorm:"'logo' varchar(255)"`
|
||
Flag string `xorm:"'flag' varchar(50)"`
|
||
Name string `xorm:"'name' varchar(50)"`
|
||
State int `xorm:"'state' TINYINT"`
|
||
CreateTime time.Time `xorm:"'create_time' datetime"`
|
||
UpdateTime time.Time `xorm:"'update_time' datetime"`
|
||
Deleted time.Time `xorm:"'Deleted' datetime"`
|
||
}
|
||
|
||
// 表名
|
||
func (m *Brand) TableName() string {
|
||
return "brand"
|
||
}
|
||
|
||
// 私有化,防止被外部new
|
||
type BrandModel struct {
|
||
db.Model //组合基础Model,集成基础Model的属性和方法
|
||
}
|
||
|
||
// 单例模式
|
||
func GetInstance() *BrandModel {
|
||
once.Do(func() {
|
||
m = new(BrandModel)
|
||
//m.DiName = "" //设置数据库实例连接,默认db.SingletonMain
|
||
})
|
||
return m
|
||
}
|