Skip to content

Commit

Permalink
Revert "[feat]: config for TLS connection in init MySQL (#1388)" (#1392)
Browse files Browse the repository at this point in the history
This reverts commit a4a240e.
  • Loading branch information
奇淼(piexlmax committed Mar 27, 2023
1 parent acd8fa3 commit 0497cf3
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
1 change: 0 additions & 1 deletion server/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ mysql:
max-open-conns: 100
log-mode: ""
log-zap: false
init-tls: false

# pgsql connect configuration
# 未初始化之前请勿手动修改数据库信息!!!如果一定要手动初始化请看(https://gin-vue-admin.com/docs/first_master)
Expand Down
1 change: 0 additions & 1 deletion server/config/db_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type GeneralDB struct {
MaxOpenConns int `mapstructure:"max-open-conns" json:"max-open-conns" yaml:"max-open-conns"` // 打开到数据库的最大连接数
LogMode string `mapstructure:"log-mode" json:"log-mode" yaml:"log-mode"` // 是否开启Gorm全局日志
LogZap bool `mapstructure:"log-zap" json:"log-zap" yaml:"log-zap"` // 是否通过zap写入日志文件
InitTls bool `mapstructure:"init-tls" json:"init-tls" yaml:"init-tls"` // 初始化时是否开启TLS
}

type SpecializedDB struct {
Expand Down
12 changes: 2 additions & 10 deletions server/model/system/request/sys_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@ type InitDB struct {
// MysqlEmptyDsn msyql 空数据库 建库链接
// Author SliverHorn
func (i *InitDB) MysqlEmptyDsn() string {
initTls := ""
if config.GeneralDB.InitTls {
initTls = "?tls=true"
}
if i.Host == "" {
i.Host = "127.0.0.1"
}
if i.Port == "" {
i.Port = "3306"
}
return fmt.Sprintf("%s:%s@tcp(%s:%s)/"+initTls, i.UserName, i.Password, i.Host, i.Port)
return fmt.Sprintf("%s:%s@tcp(%s:%s)/", i.UserName, i.Password, i.Host, i.Port)
}

// PgsqlEmptyDsn pgsql 空数据库 建库链接
Expand All @@ -46,10 +42,6 @@ func (i *InitDB) PgsqlEmptyDsn() string {
// ToMysqlConfig 转换 config.Mysql
// Author [SliverHorn](https://github.com/SliverHorn)
func (i *InitDB) ToMysqlConfig() config.Mysql {
initTls := ""
if config.GeneralDB.InitTls {
initTls = "&tls=true"
}
return config.Mysql{
GeneralDB: config.GeneralDB{
Path: i.Host,
Expand All @@ -60,7 +52,7 @@ func (i *InitDB) ToMysqlConfig() config.Mysql {
MaxIdleConns: 10,
MaxOpenConns: 100,
LogMode: "error",
Config: "charset=utf8mb4&parseTime=True&loc=Local" + initTls,
Config: "charset=utf8mb4&parseTime=True&loc=Local",
},
}
}
Expand Down

0 comments on commit 0497cf3

Please sign in to comment.