Selaa lähdekoodia

新增postgresql的Host配置

SliverHorn 4 vuotta sitten
vanhempi
commit
33c22f5d17
2 muutettua tiedostoa jossa 2 lisäystä ja 1 poistoa
  1. 1 0
      server/config/config.go
  2. 1 1
      server/initialize/gorm.go

+ 1 - 0
server/config/config.go

@@ -44,6 +44,7 @@ type Mysql struct {
 }
 
 type Postgresql struct {
+	Host                 string `mapstructure:"host" json:"host" yaml:"host"`
 	Username             string `mapstructure:"username" json:"username" yaml:"username"`
 	Password             string `mapstructure:"password" json:"password" yaml:"password"`
 	Dbname               string `mapstructure:"db-name" json:"dbname" yaml:"db-name"`

+ 1 - 1
server/initialize/gorm.go

@@ -82,7 +82,7 @@ func GormMysql() {
 // GormPostgreSql 初始化PostgreSql数据库
 func GormPostgreSql() {
 	p := global.GVA_CONFIG.Postgresql
-	dsn := "user=" + p.Username + " password=" + p.Password + " dbname=" + p.Dbname + " port=" + p.Port + " " + p.Config
+	dsn := "host="+ p.Host + " user=" + p.Username + " password=" + p.Password + " dbname=" + p.Dbname + " port=" + p.Port + " " + p.Config
 	postgresConfig := postgres.Config{
 		DSN:                  dsn,                    // DSN data source name
 		PreferSimpleProtocol: p.PreferSimpleProtocol, // 禁用隐式 prepared statement