ht_controller.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "eta/eta_mini_crm_ht/models"
  5. "eta/eta_mini_crm_ht/models/request"
  6. "eta/eta_mini_crm_ht/services"
  7. )
  8. type HTController struct {
  9. BaseAuthController
  10. }
  11. // GetIndexInfo
  12. // @Title 获取一期指标信息
  13. // @Description 获取一期指标信息
  14. // @Success 200 {object} models.LoginResp
  15. // @router /getIndexInfo [get]
  16. func (this *HTController) GetIndexInfo(IndexCode string) {
  17. br := new(models.BaseResponse).Init()
  18. defer func() {
  19. this.Data["json"] = br
  20. this.ServeJSON()
  21. }()
  22. IndexInfo, err := services.GetIndexInfo(IndexCode)
  23. if err != nil {
  24. br.Msg = "指标详情信息获取失败"
  25. br.ErrMsg = "指标详情信息获取失败,系统错误,Err:" + err.Error()
  26. return
  27. }
  28. br.Data = IndexInfo
  29. br.Ret = 200
  30. br.Msg = "指标详情信息获取成功"
  31. br.Success = true
  32. }
  33. // PushIndexInfo
  34. // @Title 添加指标信息
  35. // @Description 添加指标信息
  36. // @Success 200 {object} models.LoginResp
  37. // @router /push [post]
  38. func (this *HTController) PushIndexInfo() {
  39. br := new(models.BaseResponse).Init()
  40. defer func() {
  41. this.Data["json"] = br
  42. this.ServeJSON()
  43. }()
  44. var req request.IndexPushReq
  45. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  46. err = services.PushIndexInfo(req.IndexCode)
  47. if err != nil {
  48. br.Msg = "同步指标失败"
  49. br.ErrMsg = "同步指标失败,系统错误,Err:" + err.Error()
  50. return
  51. }
  52. br.Ret = 200
  53. br.Msg = "同步指标成功"
  54. br.Success = true
  55. }