48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
package userinfomodel
|
||
|
||
import (
|
||
"github.com/qit-team/snow-core/db"
|
||
"sync"
|
||
"time"
|
||
)
|
||
|
||
var (
|
||
once sync.Once
|
||
m *UserInfoModel
|
||
)
|
||
|
||
// 实体
|
||
type UserInfo struct {
|
||
Id int `xorm:"'Id' int(11)"`
|
||
Clientuniqueidentification string `xorm:"'ClientUniqueIdentification' varchar(255)"`
|
||
Mobile string `xorm:"'Mobile' varchar(13)"`
|
||
Status int `xorm:"'Status' TINYINT"`
|
||
Lastupdatetime time.Time `xorm:"'LastUpdateTime' datetime"`
|
||
Createtime time.Time `xorm:"'CreateTime' datetime"`
|
||
}
|
||
|
||
// 表名
|
||
func (m *UserInfo) TableName() string {
|
||
return "UserInfo"
|
||
}
|
||
|
||
// 私有化,防止被外部new
|
||
type UserInfoModel struct {
|
||
db.Model //组合基础Model,集成基础Model的属性和方法
|
||
}
|
||
|
||
// 单例模式
|
||
func GetInstance() *UserInfoModel {
|
||
once.Do(func() {
|
||
m = new(UserInfoModel)
|
||
//m.DiName = "" //设置数据库实例连接,默认db.SingletonMain
|
||
})
|
||
return m
|
||
}
|
||
|
||
func (m *UserInfoModel) GetListByMobile(mobile string, limits ...int) (banners []*UserInfo, err error) {
|
||
banners = make([]*UserInfo, 0)
|
||
err = m.GetList(&banners, "Mobile like ?", []interface{}{"%" + mobile + "%"}, limits)
|
||
return
|
||
}
|