From 16eddb135c1be35e6f56e82b63f1c11b25646c7b Mon Sep 17 00:00:00 2001 From: wuchao <1272174216@qq.com> Date: Wed, 27 Nov 2024 16:56:37 +0800 Subject: [PATCH] =?UTF-8?q?db=20=E7=AE=A1=E7=90=86=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/crondbmodel/cron_db.go | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 app/models/crondbmodel/cron_db.go 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 +}