diff --git a/app/models/crondbmodel/cron_db.go b/app/models/crondbmodel/cron_db.go new file mode 100644 index 0000000..c704cc6 --- /dev/null +++ b/app/models/crondbmodel/cron_db.go @@ -0,0 +1,44 @@ +package crondbmodel + +import ( + "github.com/qit-team/snow-core/db" + "sync" + "time" +) + +var ( + once sync.Once + m *CronDbModel +) + +// 实体 +type CronDb struct { + DbId string `xorm:"'db_id' UNSIGNED INT"` + 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' datetime"` + UpdateTime time.Time `xorm:"'update_time' timestamp"` + 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 +}