index.go 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. case utils.DATA_SOURCE_GPR_RISK:
  49. list, err = models.GetGprRiskIndex(startDate, endDate)
  50. default:
  51. }
  52. return
  53. }
  54. func GetIndexDataList(source int, indexCode, startDate, endDate string) (list interface{}, err error) {
  55. switch source {
  56. case utils.DATA_SOURCE_EIA_STEO:
  57. list, err = models.GetEiaSteoIndexData(indexCode, startDate, endDate)
  58. case utils.DATA_SOURCE_THS:
  59. list, err = models.GetEdbDataThs(indexCode, startDate, endDate)
  60. case utils.DATA_SOURCE_PB, utils.DATA_SOURCE_PB_FINANCE:
  61. list, err = models.GetEdbDataPb(indexCode, startDate, endDate)
  62. case utils.DATA_SOURCE_GFEX: //广期所
  63. list, err = models.GetBaseFromTradeGuangzhouData(indexCode, startDate, endDate)
  64. case utils.DATA_SOURCE_ICPI: //ICPI消费指数
  65. list, err = models.GetBaseFromIcpiData(indexCode, startDate, endDate)
  66. case utils.DATA_SOURCE_USDA_FAS:
  67. list, err = models.GetBaseFromUsdaFasData(indexCode, startDate, endDate)
  68. case utils.DATA_SOURCE_GPR_RISK:
  69. list, err = models.GetBaseFromGprRiskData(indexCode, startDate, endDate)
  70. default:
  71. }
  72. return
  73. }
  74. // GetIndexDataPageList 分页获取数据同步
  75. func GetIndexDataPageList(source, currPage, pageSize int, startDate, endDate string) (list interface{}, err error) {
  76. switch source {
  77. case utils.DATA_SOURCE_COM_TRADE:
  78. var total int
  79. dataList := make([]*models.ComTradeData, 0)
  80. total, dataList, err = models.GetComTradeDataList(startDate, endDate, currPage*pageSize, pageSize)
  81. if err != nil {
  82. return
  83. }
  84. page := paging.GetPaging(currPage, pageSize, total)
  85. list = models.ComTradeIndexDataResp{
  86. List: dataList,
  87. Paging: page,
  88. }
  89. case utils.DATA_SOURCE_GFEX: //广期所
  90. var total int
  91. dataList := make([]*models.BaseFromTradeGuangzhouData, 0)
  92. total, dataList, err = models.GetBaseFromTradeGuangzhouDataList(startDate, endDate, currPage*pageSize, pageSize)
  93. if err != nil {
  94. return
  95. }
  96. page := paging.GetPaging(currPage, pageSize, total)
  97. list = models.BaseFromTradeGuangzhouDataResp{
  98. List: dataList,
  99. Paging: page,
  100. }
  101. case utils.DATA_SOURCE_ICPI: //ICPI-消费指数
  102. var total int
  103. dataList := make([]*models.BaseFromIcpiData, 0)
  104. total, dataList, err = models.GetBaseFromIcpiDataList(startDate, endDate, currPage*pageSize, pageSize)
  105. if err != nil {
  106. return
  107. }
  108. page := paging.GetPaging(currPage, pageSize, total)
  109. list = models.BaseFromIcpiDataResp{
  110. List: dataList,
  111. Paging: page,
  112. }
  113. case utils.DATA_SOURCE_USDA_FAS: //美国农业部
  114. var total int
  115. dataList := make([]*models.BaseFromUsdaFasData, 0)
  116. total, dataList, err = models.GetBaseFromUsdaFasDataList(startDate, endDate, currPage*pageSize, pageSize)
  117. if err != nil {
  118. return
  119. }
  120. page := paging.GetPaging(currPage, pageSize, total)
  121. list = models.BaseFromUsdaFasDataResp{
  122. List: dataList,
  123. Paging: page,
  124. }
  125. case utils.DATA_SOURCE_GPR_RISK: //GPR地缘风险指数
  126. var total int
  127. dataList := make([]*models.BaseFromGprRiskData, 0)
  128. total, dataList, err = models.GetBaseFromGprRiskDataList(startDate, endDate, currPage*pageSize, pageSize)
  129. if err != nil {
  130. return
  131. }
  132. page := paging.GetPaging(currPage, pageSize, total)
  133. list = models.BaseFromGprRiskDataResp{
  134. List: dataList,
  135. Paging: page,
  136. }
  137. default:
  138. }
  139. return
  140. }