Commit f1704d8fdcbd8f6ee34bea2ae6ac3e56b7d000a6

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

feat✨:配置管理

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