Browse Source

Merge pull request #29 from haimait/haima_edit_admin_config

mysql 加打开日志打印模式  已采纳
main
蒋吉兆 5 years ago
committed by GitHub
parent
commit
152212132c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      QMPlusServer/config/config.go
  2. 5
      QMPlusServer/init/qmsql/initMysql.go
  3. 7
      QMPlusServer/static/config/config.json

3
QMPlusServer/config/config.go

@ -36,6 +36,9 @@ type MysqlAdmin struct { // mysql admin 数据库配置
Path string `json:"path"` Path string `json:"path"`
Dbname string `json:"dbname"` Dbname string `json:"dbname"`
Config string `json:"config"` Config string `json:"config"`
MaxIdleConns int `json:"maxIdleConns"`
MaxOpenConns int `json:"maxOpenConns"`
LogMode bool `json:"maxOpenConns"`
} }
type RedisAdmin struct { // Redis admin 数据库配置 type RedisAdmin struct { // Redis admin 数据库配置

5
QMPlusServer/init/qmsql/initMysql.go

@ -18,8 +18,9 @@ func InitMysql(admin config.MysqlAdmin) *gorm.DB {
log.Fatalf("DEFAULTDB数据库启动异常: %s", err) log.Fatalf("DEFAULTDB数据库启动异常: %s", err)
} else { } else {
DEFAULTDB = db DEFAULTDB = db
DEFAULTDB.DB().SetMaxIdleConns(10)
DEFAULTDB.DB().SetMaxOpenConns(100)
DEFAULTDB.DB().SetMaxIdleConns(admin.MaxIdleConns)
DEFAULTDB.DB().SetMaxOpenConns(admin.MaxOpenConns)
DEFAULTDB.LogMode(admin.LogMode)
} }
return DEFAULTDB return DEFAULTDB
} }

7
QMPlusServer/static/config/config.json

@ -7,10 +7,13 @@
}, },
"mysqladmin": { "mysqladmin": {
"username": "root", "username": "root",
"password": "Aa@6447985",
"password": "123456",
"path": "127.0.0.1:3306", "path": "127.0.0.1:3306",
"dbname": "qmPlus", "dbname": "qmPlus",
"config": "charset=utf8\u0026parseTime=True\u0026loc=Local"
"config": "charset=utf8\u0026parseTime=True\u0026loc=Local",
"maxIdleConns": 10,
"maxOpenConns": 100,
"logMode": true
}, },
"qiniu": { "qiniu": {
"accessKey": "25j8dYBZ2wuiy0yhwShytjZDTX662b8xiFguwxzZ", "accessKey": "25j8dYBZ2wuiy0yhwShytjZDTX662b8xiFguwxzZ",

Loading…
Cancel
Save