mini_config.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package controllers
  2. import (
  3. "eta/eta_mini_api/models"
  4. "eta/eta_mini_api/models/response"
  5. )
  6. type MiniConfigController struct {
  7. BaseCommonController
  8. }
  9. // MiniConfig
  10. // @Title 获取小程序配置项
  11. // @Description 获取小程序配置项
  12. // @Success 200 {object} response.MiniConfigResp
  13. // @router /config [get]
  14. func (this *MiniConfigController) MiniConfig() {
  15. br := new(models.BaseResponse).Init()
  16. defer func() {
  17. if br.ErrMsg == "" {
  18. br.IsSendEmail = false
  19. }
  20. this.Data["json"] = br
  21. this.ServeJSON()
  22. }()
  23. list := make([]response.MiniConfigResp, 0)
  24. miniConf, err := models.GetMiniConf()
  25. if err != nil {
  26. br.Msg = "获取小程序配置项失败"
  27. br.ErrMsg = "获取小程序配置项失败,系统异常,Err:" + err.Error()
  28. return
  29. }
  30. list = append(list, response.MiniConfigResp{
  31. ConfKey: "ChartViewUrl",
  32. ConfVal: miniConf["ChartViewUrl"],
  33. }, response.MiniConfigResp{
  34. ConfKey: "H5Url",
  35. ConfVal: miniConf["H5Url"],
  36. }, response.MiniConfigResp{
  37. ConfKey: "Disclaimers",
  38. ConfVal: miniConf["Disclaimers"],
  39. }, response.MiniConfigResp{
  40. ConfKey: "ServiceAgreement",
  41. ConfVal: miniConf["ServiceAgreement"],
  42. }, response.MiniConfigResp{
  43. ConfKey: "ServicePhone",
  44. ConfVal: miniConf["ServicePhone"],
  45. })
  46. br.Data = list
  47. br.Ret = 200
  48. br.Success = true
  49. br.Msg = "获取成功"
  50. }