Compare commits

..

2 Commits

Author SHA1 Message Date
63b497c497 增加获取数据库全部表的能力 2022-05-15 20:44:16 +08:00
9c51e86e3a 修复不需要日志时, NPE问题 2022-05-15 20:43:55 +08:00
2 changed files with 40 additions and 0 deletions

View File

@ -97,6 +97,9 @@ func getLogInstance(logConf *LogConfig, loggerInstance *zap.Logger) (*zap.Logger
if nil != loggerInstance { if nil != loggerInstance {
return loggerInstance, nil return loggerInstance, nil
} }
if nil == logConf {
return nil, nil
}
logConfList := []logger.SetLoggerOptionFunc{logger.WithEncoder(logConf.Encoder), logger.WithCallerSkip(logConf.Skip), logger.WithCaller()} logConfList := []logger.SetLoggerOptionFunc{logger.WithEncoder(logConf.Encoder), logger.WithCallerSkip(logConf.Skip), logger.WithCaller()}
if logConf.ConsoleOutput { if logConf.ConsoleOutput {
logConfList = append(logConfList, logger.WithConsoleOutput()) logConfList = append(logConfList, logger.WithConsoleOutput())

37
system.go Normal file
View File

@ -0,0 +1,37 @@
// Package mysql ...
//
// Description : mysql ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2022-05-15 19:32
package mysql
import (
"gorm.io/gorm"
)
// SystemDao 执行一些系统的mysql命令
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 19:32 2022/5/15
type SystemDao struct {
}
// GetTableList 查询数据表
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 19:36 2022/5/15
func (sd *SystemDao) GetTableList(dbInstance *gorm.DB) ([]string, error) {
var (
err error
result []string
)
if err = dbInstance.Raw("SHOW TABLES").Scan(&result).Error; nil != err {
return nil, err
}
return result, nil
}