123456789101112131415161718192021222324252627282930313233 |
- package activity
- import (
- "app.yhyue.com/moapp/jybase/api"
- "app.yhyue.com/moapp/jybase/go-xweb/xweb"
- "encoding/json"
- "fmt"
- "github.com/gogf/gf/v2/os/gcfg"
- "github.com/gogf/gf/v2/os/gctx"
- "github.com/gogf/gf/v2/util/gconv"
- "log"
- )
- type ConfigRouter struct {
- *xweb.Action
- getConfig xweb.Mapper `xweb:"/getConfig/info"`
- }
- func (c *ConfigRouter) GetConfig() {
- rData, errMsg := func() (interface{}, error) {
- reqParam := map[string]interface{}{}
- if err := json.Unmarshal(c.Body(), &reqParam); err != nil || len(reqParam) == 0 {
- return nil, fmt.Errorf("请求参数异常")
- }
- code := gconv.String(reqParam["code"])
- data := gcfg.Instance().MustGet(gctx.New(), code, nil).Map()
- return data, nil
- }()
- if errMsg != nil {
- log.Printf("ConfigRouter GetConfig error:%s\n", errMsg.Error())
- }
- c.ServeJson(api.NewResult(rData, errMsg))
- }
|