优化mysql初始化

This commit is contained in:
2022-07-15 00:38:20 +08:00
parent 46ea6042fc
commit 5965faa37f
2 changed files with 6 additions and 17 deletions

View File

@ -260,23 +260,17 @@ func (c *client) getGormClient() (*gorm.DB, error) {
// Author : go_developer@163.com<白茶清欢>
//
// Date : 18:41 2022/6/11
func (c *client) GetDatabaseClient(conf *Mysql, logConf *logger.InputLogConfig) (*gorm.DB, error) {
func (c *client) GetDatabaseClient(conf *Mysql, logInstance *zap.Logger) (*gorm.DB, error) {
var (
instance *gorm.DB
err error
loggerInstance *zap.Logger
instance *gorm.DB
err error
)
if instance, err = gorm.Open(mysql.Open(c.buildConnectionDSN(conf)), &gorm.Config{}); nil != err {
return nil, err
}
if nil != logConf {
if loggerInstance, err = c.getLogInstance(logConf); nil != err {
return nil, err
}
instance.Logger = wrapper.NewGormLoggerWithInstance(nil, instance, loggerInstance, "", nil)
}
instance.Logger = wrapper.NewGormLoggerWithInstance(nil, instance, logInstance, "", nil)
return instance, nil
}