mini_config.go 1.5 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. // @Title 获取小程序配置项
  10. // @Description 获取小程序配置项
  11. // @Param ReportId query int true "报告id"
  12. // @Param chartPermissionId query int true "品种ID"
  13. // @Param PageSize query int true "每页数据条数"
  14. // @Param CurrentIndex query int true "当前页页码,从1开始"
  15. // @Success 200 {object} models.ReportDetailResp
  16. // @router /config [get]
  17. func (this *MiniConfigController) MiniConfig() {
  18. br := new(models.BaseResponse).Init()
  19. defer func() {
  20. if br.ErrMsg == "" {
  21. br.IsSendEmail = false
  22. }
  23. this.Data["json"] = br
  24. this.ServeJSON()
  25. }()
  26. list := make([]response.MiniConfigResp, 0)
  27. miniConf, err := models.GetMiniConf()
  28. if err != nil {
  29. br.Msg = "获取小程序配置项失败"
  30. br.ErrMsg = "获取小程序配置项失败,系统异常,Err:" + err.Error()
  31. return
  32. }
  33. etaConf, err := models.GetEtaConf()
  34. if err != nil {
  35. br.Msg = "获取小程序配置项失败"
  36. br.ErrMsg = "获取程序配置项失败,系统异常,Err:" + err.Error()
  37. return
  38. }
  39. list = append(list, response.MiniConfigResp{
  40. ConfKey: "ChartViewUrl",
  41. ConfVal: etaConf["ChartViewUrl"],
  42. }, response.MiniConfigResp{
  43. ConfKey: "H5Url",
  44. ConfVal: miniConf["H5Url"],
  45. })
  46. br.Data = list
  47. br.Ret = 200
  48. br.Success = true
  49. br.Msg = "获取成功"
  50. }