YouChuKoffee/app/models/brandmodel/brand.go

44 lines
946 B
Go
Raw Normal View History

2024-06-17 16:29:39 +08:00
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
}