fix: 修复多库模式不能使用 pg 的问题
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package initialize
|
||||
|
||||
import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/config"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -15,9 +16,9 @@ func DBList() {
|
||||
}
|
||||
switch info.Type {
|
||||
case "mysql":
|
||||
dbMap[info.Dbname] = GormMysqlByConfig(info)
|
||||
dbMap[info.GeneralDB.Dbname] = GormMysqlByConfig(config.Mysql{GeneralDB: info.GeneralDB})
|
||||
case "pgsql":
|
||||
dbMap[info.Dbname] = GormPgSqlByConfig(info)
|
||||
dbMap[info.GeneralDB.Dbname] = GormPgSqlByConfig(config.Pgsql{GeneralDB: info.GeneralDB})
|
||||
default:
|
||||
continue
|
||||
}
|
||||
|
@@ -32,7 +32,7 @@ func GormMysql() *gorm.DB {
|
||||
}
|
||||
|
||||
// GormMysqlByConfig 初始化Mysql数据库用过传入配置
|
||||
func GormMysqlByConfig(m config.DB) *gorm.DB {
|
||||
func GormMysqlByConfig(m config.Mysql) *gorm.DB {
|
||||
if m.Dbname == "" {
|
||||
return nil
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ func GormPgSql() *gorm.DB {
|
||||
}
|
||||
|
||||
// GormPgSqlByConfig 初始化 Postgresql 数据库 通过参数
|
||||
func GormPgSqlByConfig(p config.DB) *gorm.DB {
|
||||
func GormPgSqlByConfig(p config.Pgsql) *gorm.DB {
|
||||
if p.Dbname == "" {
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user