edb_info_calculate_mapping.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "eta/eta_data_push/models"
  5. )
  6. // 计算指标
  7. type EdbInfoCalculateController struct {
  8. BaseAuthController
  9. }
  10. // @Title 获取计算指标信息映射信息
  11. // @Description 获取计算指标信息映射信息
  12. // @Param request body models.EdbInfoCalculateItemReq true "type json string"
  13. // @Success 200 {object} models.EdbInfoCalculateMapping
  14. // @router /item [post]
  15. func (this *EdbInfoCalculateController) EdbInfoCalculateItem() {
  16. br := new(models.BaseResponse).Init()
  17. defer func() {
  18. this.Data["json"] = br
  19. this.ServeJSON()
  20. }()
  21. var req models.EdbInfoCalculateItemReq
  22. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  23. if err != nil {
  24. br.Msg = "参数解析异常!"
  25. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  26. return
  27. }
  28. if req.EdbCode == "" {
  29. br.Msg = "请输入指标编码!"
  30. return
  31. }
  32. items, err := models.GetEdbInfoCalculateMappingByEdbCode(req.EdbCode)
  33. if err != nil {
  34. br.Msg = "获取数据失败!"
  35. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  36. return
  37. }
  38. br.Ret = 200
  39. br.Success = true
  40. br.Msg = "获取成功"
  41. br.Data = items
  42. }