56 lines
1.7 KiB
Go
56 lines
1.7 KiB
Go
|
package activitymodel
|
|||
|
|
|||
|
import (
|
|||
|
"github.com/qit-team/snow-core/db"
|
|||
|
"sync"
|
|||
|
"time"
|
|||
|
)
|
|||
|
|
|||
|
var (
|
|||
|
once sync.Once
|
|||
|
m *ActivityModel
|
|||
|
)
|
|||
|
|
|||
|
// 实体
|
|||
|
type Activity struct {
|
|||
|
Id int `xorm:"'id' UNSIGNED INT pk autoincr"`
|
|||
|
Name string `xorm:"'name' varchar(255)"`
|
|||
|
Type string `xorm:"'type' UNSIGNED TINYINT"`
|
|||
|
State int `xorm:"'state' TINYINT"`
|
|||
|
StartTime time.Time `xorm:"'start_time' datetime"`
|
|||
|
ExpiredTime time.Time `xorm:"'expired_time' datetime"`
|
|||
|
UsersWhiteId string `xorm:"'users_white_id' varchar(50)"`
|
|||
|
Sort string `xorm:"'sort' UNSIGNED SMALLINT"`
|
|||
|
Banner string `xorm:"'banner' varchar(255)"`
|
|||
|
Stock int `xorm:"'stock' int(0)"`
|
|||
|
ProductIds string `xorm:"'product_ids' varchar(255)"`
|
|||
|
Limitation string `xorm:"'limitation' UNSIGNED TINYINT"`
|
|||
|
LimitationNum string `xorm:"'limitation_num' UNSIGNED SMALLINT"`
|
|||
|
CumJoinNum int `xorm:"'cum_join_num' int(0)"`
|
|||
|
Description string `xorm:"'description' varchar(255)"`
|
|||
|
Rule string `xorm:"'rule' JSON"`
|
|||
|
CreateTime time.Time `xorm:"'create_time' datetime"`
|
|||
|
ManagerId string `xorm:"'manager_id' UNSIGNED INT"`
|
|||
|
UpdateTime time.Time `xorm:"'update_time' datetime"`
|
|||
|
DeleteTime time.Time `xorm:"'Deleted' datetime"`
|
|||
|
}
|
|||
|
|
|||
|
// 表名
|
|||
|
func (m *Activity) TableName() string {
|
|||
|
return "activity"
|
|||
|
}
|
|||
|
|
|||
|
// 私有化,防止被外部new
|
|||
|
type ActivityModel struct {
|
|||
|
db.Model //组合基础Model,集成基础Model的属性和方法
|
|||
|
}
|
|||
|
|
|||
|
// 单例模式
|
|||
|
func GetInstance() *ActivityModel {
|
|||
|
once.Do(func() {
|
|||
|
m = new(ActivityModel)
|
|||
|
//m.DiName = "" //设置数据库实例连接,默认db.SingletonMain
|
|||
|
})
|
|||
|
return m
|
|||
|
}
|