Commit 4fb31ddd by zhengqiuyun86

返回封装优化

parent 21e9de18
......@@ -111,20 +111,25 @@ func Init() {
conf.MySql.User, conf.MySql.Password, conf.MySql.Host, conf.MySql.Port, conf.MySql.NameSpace)), &gorm.Config{
Logger: newLogger,
})
sqlDB, err := customerDb.DB()
if conf.MySql.MaxIdleConns == 0 {
sqlDB.SetMaxIdleConns(10)
} else {
sqlDB.SetMaxIdleConns(conf.MySql.MaxIdleConns)
}
if conf.MySql.MaxOpenConns == 0 {
sqlDB.SetMaxOpenConns(10)
} else {
sqlDB.SetMaxOpenConns(conf.MySql.MaxOpenConns)
}
if err != nil {
log.Error(fmt.Sprintf("%s connect error:%s", "Mysql server", err.Error()))
} else {
log.Info(fmt.Sprintf("%s connect success", "Mysql server"))
sqlDB, err := customerDb.DB()
if conf.MySql.MaxIdleConns == 0 {
sqlDB.SetMaxIdleConns(10)
} else {
sqlDB.SetMaxIdleConns(conf.MySql.MaxIdleConns)
}
if conf.MySql.MaxOpenConns == 0 {
sqlDB.SetMaxOpenConns(10)
} else {
sqlDB.SetMaxOpenConns(conf.MySql.MaxOpenConns)
}
if err != nil {
log.Error(fmt.Sprintf("%s connect error:%s", "Mysql server", err.Error()))
} else {
log.Info(fmt.Sprintf("%s connect success", "Mysql server"))
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment