From 5010beb9012d64fb9062e5bae0d0b3023e8ca664 Mon Sep 17 00:00:00 2001 From: viletyy Date: Sat, 26 Sep 2020 13:34:54 +0800 Subject: [PATCH] =?UTF-8?q?[FIX]=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/app.ini | 38 ++++++++++++++++++++++++-------------- models/models.go | 14 +++++++------- pkg/setting/setting.go | 13 +++++++------ 3 files changed, 38 insertions(+), 27 deletions(-) diff --git a/conf/app.ini b/conf/app.ini index ba64af8..774bf21 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -1,19 +1,29 @@ -RUN_MODE = debug - [app] -PAGE_SIZE = 10 -JWT_SECRET = 23347$040412 +PageSize = 10 +JwtSecret = 233 + +RuntimeRootPath = runtime/ +ImagePrefixUrl = http://127.0.0.8002 +ImageSavePath = upload/images/ +ImageMaxSize = 5 +ImageAllowExts = .jpg,.jpeg,.png + +logSavePath = logs/ +LogSaveName = log +LogFileExt = log +TimeFormat = 20060102 [server] -HTTP_PORT = 8002 -READ_TIMEOUT = 60 -WRITE_TIMEOUT = 60 +RunMode = debug +HttpPort = 8002 +ReadTimeout = 60 +WriteTimeout = 60 [database] -TYPE = postgres -USER = virus -PASSWORD = a19960425 -HOST = 0.0.0.0 -PORT = 5432 -NAME = shop -TABLE_PREFIX = shop_ +Type = postgres +User = virus +Password = a19960425 +Host = 0.0.0.0 +Port = 5432 +Name = shop +TablePrefix = shop_ diff --git a/models/models.go b/models/models.go index 0219c60..cdb7c7c 100644 --- a/models/models.go +++ b/models/models.go @@ -29,13 +29,13 @@ func init() { log.Fatal(2, "Fail to get section 'database': %v", err) } - dbType = sec.Key("TYPE").String() - dbName = sec.Key("NAME").String() - user = sec.Key("USER").String() - password = sec.Key("PASSWORD").String() - host = sec.Key("HOST").String() - port = sec.Key("PORT").String() - tablePrefix = sec.Key("TABLE_PREFIX").String() + dbType = sec.Key("Type").String() + dbName = sec.Key("Name").String() + user = sec.Key("User").String() + password = sec.Key("Password").String() + host = sec.Key("Host").String() + port = sec.Key("Port").String() + tablePrefix = sec.Key("TablePrefix").String() db, err = gorm.Open(dbType, fmt.Sprintf("host=%s user=%s dbname=%s port=%s sslmode=disable password=%s", host, diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index 3dea4f7..4f01f10 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -29,7 +29,7 @@ func init() { } func LoadBase() { - RunMode = Cfg.Section("").Key("RUN_MODE").MustString("debug") + //RunMode = Cfg.Section("server").Key("RUN_MODE").MustString("debug") } func LoadServer() { @@ -38,9 +38,10 @@ func LoadServer() { log.Fatalf("Fail to get section 'sever' : %v", err) } - HTTPPort = sec.Key("HTTP_PORT").MustInt(8000) - ReadTimeout = time.Duration(sec.Key("READ_TIMEOUT").MustUint(60)) * time.Second - WriteTimeout = time.Duration(sec.Key("WRITE_TIMEOUT").MustInt(60)) * time.Second + RunMode = sec.Key("RunMode").MustString("debug") + HTTPPort = sec.Key("HttpPort").MustInt(8000) + ReadTimeout = time.Duration(sec.Key("ReadTimeout").MustUint(60)) * time.Second + WriteTimeout = time.Duration(sec.Key("WriteTimeout").MustInt(60)) * time.Second } func LoadApp() { @@ -49,6 +50,6 @@ func LoadApp() { log.Fatalf("Fail to get section 'app':%v", err) } - JwtSecret = sec.Key("JWT_SECRET").MustString("!@#!@#!@#!@@#!@#") - PageSize = sec.Key("PAGE_SIZE").MustInt(10) + JwtSecret = sec.Key("JwtSecret").MustString("!@#!@#!@#!@@#!@#") + PageSize = sec.Key("WriteTimeout").MustInt(10) }