index.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. package xiangyu
  2. import (
  3. "eta/eta_bridge/controller/resp"
  4. "eta/eta_bridge/global"
  5. "eta/eta_bridge/logic/xiangyu"
  6. xiangyuSrc "eta/eta_bridge/services/xiangyu"
  7. "github.com/gin-gonic/gin"
  8. "github.com/go-playground/validator/v10"
  9. )
  10. // PushIndexDataResp
  11. // @Description: 指标信息推送
  12. // @author: Roc
  13. // @receiver xc
  14. // @datetime 2024-02-27 17:53:24
  15. // @param c *gin.Context
  16. func (xc *XiangyuController) PushIndexDataResp(c *gin.Context) {
  17. var req xiangyuSrc.PushBaseParamReq
  18. if e := c.Bind(&req); e != nil {
  19. err, ok := e.(validator.ValidationErrors)
  20. if !ok {
  21. resp.FailData("参数解析失败", "Err:"+e.Error(), c)
  22. return
  23. }
  24. resp.FailData("参数解析失败", err.Translate(global.Trans), c)
  25. return
  26. }
  27. err, errMsg := xiangyu.PushIndexDataResp(req)
  28. if err != nil {
  29. resp.FailData(errMsg, err.Error(), c)
  30. return
  31. }
  32. resp.OkData("同步成功", "", c)
  33. return
  34. }
  35. // PushIndexValueDataResp
  36. // @Description: 指标日期值信息推送
  37. // @author: Roc
  38. // @receiver xc
  39. // @datetime 2024-02-27 17:53:24
  40. // @param c *gin.Context
  41. func (xc *XiangyuController) PushIndexValueDataResp(c *gin.Context) {
  42. var req xiangyuSrc.PushBaseParamReq
  43. if e := c.Bind(&req); e != nil {
  44. err, ok := e.(validator.ValidationErrors)
  45. if !ok {
  46. resp.FailData("参数解析失败", "Err:"+e.Error(), c)
  47. return
  48. }
  49. resp.FailData("参数解析失败", err.Translate(global.Trans), c)
  50. return
  51. }
  52. err, errMsg := xiangyu.PushEdbValueDataResp(req)
  53. if err != nil {
  54. resp.FailData(errMsg, err.Error(), c)
  55. return
  56. }
  57. resp.OkData("同步成功", "", c)
  58. return
  59. }
  60. // PushClassifyDataResp
  61. // @Description: 指标分类信息推送
  62. // @author: Roc
  63. // @receiver xc
  64. // @datetime 2024-02-27 17:53:24
  65. // @param c *gin.Context
  66. func (xc *XiangyuController) PushClassifyDataResp(c *gin.Context) {
  67. var req xiangyuSrc.PushBaseParamReq
  68. if e := c.Bind(&req); e != nil {
  69. err, ok := e.(validator.ValidationErrors)
  70. if !ok {
  71. resp.FailData("参数解析失败", "Err:"+e.Error(), c)
  72. return
  73. }
  74. resp.FailData("参数解析失败", err.Translate(global.Trans), c)
  75. return
  76. }
  77. err, errMsg := xiangyu.PushClassifyDataResp(req)
  78. if err != nil {
  79. resp.FailData(errMsg, err.Error(), c)
  80. return
  81. }
  82. resp.OkData("同步成功", "", c)
  83. return
  84. }
  85. // PushEdbClassifyDataResp
  86. // @Description: 指标与分类的关系信息推送
  87. // @author: Roc
  88. // @receiver xc
  89. // @datetime 2024-02-27 17:53:24
  90. // @param c *gin.Context
  91. func (xc *XiangyuController) PushEdbClassifyDataResp(c *gin.Context) {
  92. var req xiangyuSrc.PushBaseParamReq
  93. if e := c.Bind(&req); e != nil {
  94. err, ok := e.(validator.ValidationErrors)
  95. if !ok {
  96. resp.FailData("参数解析失败", "Err:"+e.Error(), c)
  97. return
  98. }
  99. resp.FailData("参数解析失败", err.Translate(global.Trans), c)
  100. return
  101. }
  102. err, errMsg := xiangyu.PushEdbClassifyDataResp(req)
  103. if err != nil {
  104. resp.FailData(errMsg, err.Error(), c)
  105. return
  106. }
  107. resp.OkData("同步成功", "", c)
  108. return
  109. }