Skip to content

Commit 54e7043

Browse files
committed
feat:viper write back
1 parent a68b2c5 commit 54e7043

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

server/service/system/sys_initdb_mysql.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
1111
"github.com/flipped-aurora/gin-vue-admin/server/source/example"
1212
"github.com/flipped-aurora/gin-vue-admin/server/source/system"
13-
"github.com/flipped-aurora/gin-vue-admin/server/utils"
1413
uuid "github.com/satori/go.uuid"
1514
"gorm.io/driver/mysql"
1615
"gorm.io/gorm"
@@ -21,10 +20,7 @@ import (
2120
// Author [songzhibin97](https://github.com/songzhibin97)
2221
func (initDBService *InitDBService) writeMysqlConfig(mysql config.Mysql) error {
2322
global.GVA_CONFIG.Mysql = mysql
24-
cs := utils.StructToMap(global.GVA_CONFIG)
25-
for k, v := range cs {
26-
global.GVA_VP.Set(k, v)
27-
}
23+
global.GVA_VP.Set("mysql", mysql)
2824
global.GVA_VP.Set("jwt.signing-key", uuid.NewV4().String())
2925
return global.GVA_VP.WriteConfig()
3026
}

server/service/system/sys_initdb_pgsql.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
1010
"github.com/flipped-aurora/gin-vue-admin/server/source/example"
1111
"github.com/flipped-aurora/gin-vue-admin/server/source/system"
12-
"github.com/flipped-aurora/gin-vue-admin/server/utils"
1312
uuid "github.com/satori/go.uuid"
1413
"gorm.io/driver/postgres"
1514
"gorm.io/gorm"
@@ -20,10 +19,7 @@ import (
2019
func (initDBService *InitDBService) writePgsqlConfig(pgsql config.Pgsql) error {
2120
global.GVA_CONFIG.System.DbType = "pgsql"
2221
global.GVA_CONFIG.Pgsql = pgsql
23-
cs := utils.StructToMap(global.GVA_CONFIG)
24-
for k, v := range cs {
25-
global.GVA_VP.Set(k, v)
26-
}
22+
global.GVA_VP.Set("pgsql", pgsql)
2723
global.GVA_VP.Set("jwt.signing-key", uuid.NewV4().String())
2824
return global.GVA_VP.WriteConfig()
2925
}

0 commit comments

Comments
 (0)