This commit is contained in:
TsMask
2023-08-22 19:25:39 +08:00
parent 38d3b7450e
commit 96de169777
45 changed files with 881 additions and 676 deletions

25
core/db/mysql.go Normal file
View File

@@ -0,0 +1,25 @@
package db
import (
"omc/conf"
"github.com/aceld/zinx/zlog"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
var Client *gorm.DB
func Init() error {
d, err := gorm.Open(mysql.Open(conf.OmcConf.Mysql), &gorm.Config{})
if err != nil {
zlog.Ins().ErrorF("open mysql %s error, ", conf.OmcConf.Mysql, err)
panic(err)
}
sqlDB, _ := d.DB()
sqlDB.SetMaxOpenConns(20)
sqlDB.SetMaxIdleConns(10)
Client = d
return nil
}