2024-06-12 19:11:00 +08:00
|
|
|
|
package usersmodel
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/qit-team/snow-core/db"
|
|
|
|
|
"sync"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
|
once sync.Once
|
|
|
|
|
m *UsersModel
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// 实体
|
|
|
|
|
type Users struct {
|
2024-06-13 18:45:49 +08:00
|
|
|
|
Id int `xorm:"'id' UNSIGNED INT pk autoincr"`
|
|
|
|
|
Name string `xorm:"'name' varchar(128)"`
|
|
|
|
|
Phone string `xorm:"'phone' char(11)"`
|
|
|
|
|
DeleteTime time.Time `xorm:"'Deleted' datetime"`
|
|
|
|
|
XinYeUserId int `xorm:"'xinye_user_id' int(10)"`
|
|
|
|
|
CreateTime time.Time `xorm:"'create_time' datetime"`
|
|
|
|
|
Status int `xorm:"'status' UNSIGNED TINYINT"`
|
|
|
|
|
UpdateTime time.Time `xorm:"'update_time' datetime"`
|
2024-06-12 19:11:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 表名
|
|
|
|
|
func (m *Users) TableName() string {
|
|
|
|
|
return "users"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 私有化,防止被外部new
|
|
|
|
|
type UsersModel struct {
|
|
|
|
|
db.Model //组合基础Model,集成基础Model的属性和方法
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 单例模式
|
|
|
|
|
func GetInstance() *UsersModel {
|
|
|
|
|
once.Do(func() {
|
|
|
|
|
m = new(UsersModel)
|
|
|
|
|
//m.DiName = "" //设置数据库实例连接,默认db.SingletonMain
|
|
|
|
|
})
|
|
|
|
|
return m
|
|
|
|
|
}
|