package crondbmodel import ( "github.com/qit-team/snow-core/db" "sync" "time" ) var ( once sync.Once m *CronDbModel ) // 实体 type CronDb struct { DbId int `xorm:"'db_id' UNSIGNED INT pk autoincr"` DbName string `xorm:"'db_name' varchar(20)"` DbType string `xorm:"'db_type' varchar(10)"` DbPermission int `xorm:"'db_permission' TINYINT"` Source string `xorm:"'source' varchar(150)"` Desc string `xorm:"'desc' varchar(200)"` CreateTime *time.Time `xorm:"'create_time' created datetime"` UpdateTime time.Time `xorm:"'update_time' updated timestamp"` DeletedTime time.Time `xorm:"'deleted_time' deleted datetime"` Status int `xorm:"'status' TINYINT"` } // 表名 func (m *CronDb) TableName() string { return "cron_db" } // 私有化,防止被外部new type CronDbModel struct { db.Model //组合基础Model,集成基础Model的属性和方法 } // 单例模式 func GetInstance() *CronDbModel { once.Do(func() { m = new(CronDbModel) //m.DiName = "" //设置数据库实例连接,默认db.SingletonMain }) return m }