edb_refresh.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "eta_gn/eta_index_lib/models"
  5. edb_refreshMol "eta_gn/eta_index_lib/models/edb_refresh"
  6. "eta_gn/eta_index_lib/models/edb_refresh/request"
  7. "eta_gn/eta_index_lib/services/edb_refresh"
  8. "eta_gn/eta_index_lib/utils"
  9. )
  10. type EdbRefreshController struct {
  11. BaseAuthController
  12. }
  13. // GetMysteelIndexConfigList
  14. // @Title 获取钢联的刷新配置
  15. // @Description 获取钢联的刷新配置
  16. // @Success 200 {object}
  17. // @router /config/mysteel_index/list [post]
  18. func (this *EdbRefreshController) GetMysteelIndexConfigList() {
  19. br := new(models.BaseResponse).Init()
  20. defer func() {
  21. this.Data["json"] = br
  22. this.ServeJSON()
  23. }()
  24. list, err := edb_refresh.GetPreviousHalfHourDefaultConfigList(utils.DATA_SOURCE_MYSTEEL_CHEMICAL, 0)
  25. if err != nil {
  26. br.Msg = "获取失败"
  27. br.ErrMsg = "获取失败,ERR:" + err.Error()
  28. }
  29. br.Ret = 200
  30. br.Success = true
  31. br.Msg = "获取成功"
  32. br.Data = list
  33. }
  34. // GetSmmConfigList
  35. // @Title 获取有色的刷新配置
  36. // @Description 获取有色的刷新配置
  37. // @Success 200 {object}
  38. // @router /config/smm/list [post]
  39. func (this *EdbRefreshController) GetSmmConfigList() {
  40. br := new(models.BaseResponse).Init()
  41. defer func() {
  42. this.Data["json"] = br
  43. this.ServeJSON()
  44. }()
  45. list, err := edb_refresh.GetPreviousHalfHourDefaultConfigList(utils.DATA_SOURCE_YS, 0)
  46. if err != nil {
  47. br.Msg = "获取失败"
  48. br.ErrMsg = "获取失败,ERR:" + err.Error()
  49. }
  50. br.Ret = 200
  51. br.Success = true
  52. br.Msg = "获取成功"
  53. br.Data = list
  54. }
  55. // GetDefaultConfigList
  56. // @Title 获取默认的刷新配置
  57. // @Description 获取默认的刷新配置
  58. // @Success 200 {object}
  59. // @router /config/default/list [post]
  60. func (this *EdbRefreshController) GetDefaultConfigList() {
  61. br := new(models.BaseResponse).Init()
  62. defer func() {
  63. this.Data["json"] = br
  64. this.ServeJSON()
  65. }()
  66. var req request.GetEdbRefreshConfigReq
  67. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  68. if err != nil {
  69. br.Msg = "参数解析异常!"
  70. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  71. return
  72. }
  73. condition := ` AND source = ? AND sub_source = ? `
  74. pars := make([]interface{}, 0)
  75. pars = append(pars, req.Source, req.SubSource)
  76. list, err := edb_refreshMol.GetListByCondition(condition, pars)
  77. if err != nil {
  78. return
  79. }
  80. if err != nil {
  81. br.Msg = "获取失败"
  82. br.ErrMsg = "获取失败,ERR:" + err.Error()
  83. }
  84. br.Ret = 200
  85. br.Success = true
  86. br.Msg = "获取成功"
  87. br.Data = list
  88. }