index.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. package services
  2. import (
  3. "eta/eta_data_push/models"
  4. "eta/eta_data_push/utils"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. )
  7. func GetIndexList(source int, startDate, endDate string) (list interface{}, err error) {
  8. switch source {
  9. case utils.DATA_SOURCE_ZZ:
  10. list, err = models.GetTradeZhengzhouIndex(startDate, endDate)
  11. case utils.DATA_SOURCE_DL:
  12. list, err = models.GetTradeDalianIndex(startDate, endDate)
  13. case utils.DATA_SOURCE_SH:
  14. list, err = models.GetTradeShanghaiIndex(startDate, endDate)
  15. case utils.DATA_SOURCE_CFFEX:
  16. list, err = models.GetTradeCffexIndex(startDate, endDate)
  17. case utils.DATA_SOURCE_SHFE:
  18. list, err = models.GetTradeIneIndex(startDate, endDate)
  19. case utils.DATA_SOURCE_GOOGLE_TRAVEL:
  20. list, err = models.GetChangesVisitorsCovid(startDate, endDate)
  21. case utils.DATA_SOURCE_EIA_STEO:
  22. list, err = models.GetEiaSteoIndex(startDate, endDate)
  23. case utils.DATA_SOURCE_GIE:
  24. list, err = models.GetEicIndex(startDate, endDate)
  25. case utils.DATA_SOURCE_COM_TRADE:
  26. indexList := make([]*models.ComTradeIndex, 0)
  27. mappingList := make([]*models.ComTradeCodeMapping, 0)
  28. indexList, err = models.GetComTradeIndex(startDate, endDate)
  29. if err != nil {
  30. return
  31. }
  32. mappingList, err = models.GetComTradeCodeMappingList(startDate, endDate)
  33. if err != nil {
  34. return
  35. }
  36. list = models.ComTradeIndexAndDataResp{
  37. IndexList: indexList,
  38. MappingList: mappingList,
  39. }
  40. case 61:
  41. list, err = models.GetMeetingProbabilities(startDate, endDate)
  42. case utils.DATA_SOURCE_GFEX:
  43. list, err = models.GetBaseFromTradeGuangzhouIndex(startDate, endDate)
  44. case utils.DATA_SOURCE_ICPI:
  45. list, err = models.GetIcpiIndex(startDate, endDate)
  46. case utils.DATA_SOURCE_USDA_FAS:
  47. list, err = models.GetUsdaFasIndex(startDate, endDate)
  48. default:
  49. }
  50. return
  51. }
  52. func GetIndexDataList(source int, indexCode, startDate, endDate string) (list interface{}, err error) {
  53. switch source {
  54. case utils.DATA_SOURCE_EIA_STEO:
  55. list, err = models.GetEiaSteoIndexData(indexCode, startDate, endDate)
  56. case utils.DATA_SOURCE_THS:
  57. list, err = models.GetEdbDataThs(indexCode, startDate, endDate)
  58. case utils.DATA_SOURCE_PB, utils.DATA_SOURCE_PB_FINANCE:
  59. list, err = models.GetEdbDataPb(indexCode, startDate, endDate)
  60. case utils.DATA_SOURCE_GFEX: //广期所
  61. list, err = models.GetBaseFromTradeGuangzhouData(indexCode, startDate, endDate)
  62. case utils.DATA_SOURCE_ICPI: //ICPI消费指数
  63. list, err = models.GetBaseFromIcpiData(indexCode, startDate, endDate)
  64. case utils.DATA_SOURCE_USDA_FAS:
  65. list, err = models.GetBaseFromUsdaFasData(indexCode, startDate, endDate)
  66. default:
  67. }
  68. return
  69. }
  70. // GetIndexDataPageList 分页获取数据同步
  71. func GetIndexDataPageList(source, currPage, pageSize int, startDate, endDate string) (list interface{}, err error) {
  72. switch source {
  73. case utils.DATA_SOURCE_COM_TRADE:
  74. var total int
  75. dataList := make([]*models.ComTradeData, 0)
  76. total, dataList, err = models.GetComTradeDataList(startDate, endDate, currPage*pageSize, pageSize)
  77. if err != nil {
  78. return
  79. }
  80. page := paging.GetPaging(currPage, pageSize, total)
  81. list = models.ComTradeIndexDataResp{
  82. List: dataList,
  83. Paging: page,
  84. }
  85. case utils.DATA_SOURCE_GFEX: //广期所
  86. var total int
  87. dataList := make([]*models.BaseFromTradeGuangzhouData, 0)
  88. total, dataList, err = models.GetBaseFromTradeGuangzhouDataList(startDate, endDate, currPage*pageSize, pageSize)
  89. if err != nil {
  90. return
  91. }
  92. page := paging.GetPaging(currPage, pageSize, total)
  93. list = models.BaseFromTradeGuangzhouDataResp{
  94. List: dataList,
  95. Paging: page,
  96. }
  97. case utils.DATA_SOURCE_ICPI: //ICPI-消费指数
  98. var total int
  99. dataList := make([]*models.BaseFromIcpiData, 0)
  100. total, dataList, err = models.GetBaseFromIcpiDataList(startDate, endDate, currPage*pageSize, pageSize)
  101. if err != nil {
  102. return
  103. }
  104. page := paging.GetPaging(currPage, pageSize, total)
  105. list = models.BaseFromIcpiDataResp{
  106. List: dataList,
  107. Paging: page,
  108. }
  109. case utils.DATA_SOURCE_USDA_FAS: //美国农业部
  110. var total int
  111. dataList := make([]*models.BaseFromUsdaFasData, 0)
  112. total, dataList, err = models.GetBaseFromUsdaFasDataList(startDate, endDate, currPage*pageSize, pageSize)
  113. if err != nil {
  114. return
  115. }
  116. page := paging.GetPaging(currPage, pageSize, total)
  117. list = models.BaseFromUsdaFasDataResp{
  118. List: dataList,
  119. Paging: page,
  120. }
  121. default:
  122. }
  123. return
  124. }