Commit f1704d8fdcbd8f6ee34bea2ae6ac3e56b7d000a6

Authored by 王家文
1 parent 74e1d4d3
Exists in master

feat✨:配置管理

.gitignore
... ... @@ -4,4 +4,5 @@ bin
4 4 bat
5 5 apigame.exe
6 6 apigame.exe~
7   -*.bat
8 7 \ No newline at end of file
  8 +*.bat
  9 +logs
9 10 \ No newline at end of file
... ...
conf/local.conf
... ... @@ -20,11 +20,14 @@ sdkdb = 8
20 20 sdkprefix = wxapi::
21 21  
22 22 [log]
23   -path = /var/logs/apigame/
  23 +path = ./logs/
24 24 maxlines = 1000000
25 25 maxdays = 1000
26 26 rotate = true
27 27 dellogger = false
28 28 level = 1
29 29  
  30 +[conf]
  31 +path = ./conf/bytes
  32 +
30 33 include "/conf/local.conf"
31 34 \ No newline at end of file
... ...
conf/pre.conf
... ... @@ -27,5 +27,7 @@ rotate = true
27 27 dellogger = false
28 28 level = 8
29 29  
  30 +[conf]
  31 +path = /home/etc/apigame/bytes
30 32  
31 33 include "conf/pre.conf"
32 34 \ No newline at end of file
... ...
conf/prod.conf
... ... @@ -28,5 +28,7 @@ rotate = true
28 28 dellogger = false
29 29 level = 5
30 30  
  31 +[conf]
  32 +path = /goexec/exec/apigame/bytes
31 33  
32 34 include "conf/prod.conf"
33 35 \ No newline at end of file
... ...
configs/external.go
... ... @@ -2,12 +2,14 @@ package configs
2 2  
3 3 import (
4 4 "fmt"
  5 + "github.com/astaxie/beego"
5 6 "reflect"
6 7 )
7 8  
8 9 func Init() bool {
9 10 fmt.Println("configs Init")
10   - Initial("./conf/bytes", "ID")
  11 + conf, _ := beego.AppConfig.GetSection("conf")
  12 + Initial(conf["path"], "ID")
11 13  
12 14 //InitExt()
13 15 return true
... ...
controllers/demo.go
... ... @@ -4,7 +4,6 @@ import (
4 4 "apigame/configs"
5 5 "apigame/models"
6 6 "apigame/service/code-msg"
7   - "apigame/util/zjson"
8 7 "encoding/json"
9 8 "fmt"
10 9 )
... ... @@ -49,7 +48,8 @@ func (c *DemoController) Demo() {
49 48 // conf := dt.(*configs.AbTestCfg)
50 49 // fmt.Println(conf)
51 50 //}
52   - fmt.Println("cs", zjson.Str(cs))
  51 + //fmt.Println("cs", zjson.Str(cs))
  52 + rsp.Data = cs
53 53 }
54 54  
55 55 c.RetRspCodeData(code_msg.RECODE_OK, rsp)
... ...
models/demo.go
... ... @@ -8,6 +8,7 @@ type ReqDemo struct {
8 8  
9 9 // RspDemo 返回
10 10 type RspDemo struct {
  11 + Data any `form:"data" json:"data"`
11 12 }
12 13  
13 14 // ReqDump 请求
... ...