123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- package services
- import (
- "eta/eta_data_push/models"
- "eta/eta_data_push/utils"
- "github.com/rdlucklib/rdluck_tools/paging"
- )
- func GetIndexList(source int, startDate, endDate string) (list interface{}, err error) {
- switch source {
- case utils.DATA_SOURCE_ZZ:
- list, err = models.GetTradeZhengzhouIndex(startDate, endDate)
- case utils.DATA_SOURCE_DL:
- list, err = models.GetTradeDalianIndex(startDate, endDate)
- case utils.DATA_SOURCE_SH:
- list, err = models.GetTradeShanghaiIndex(startDate, endDate)
- case utils.DATA_SOURCE_CFFEX:
- list, err = models.GetTradeCffexIndex(startDate, endDate)
- case utils.DATA_SOURCE_SHFE:
- list, err = models.GetTradeIneIndex(startDate, endDate)
- case utils.DATA_SOURCE_GOOGLE_TRAVEL:
- list, err = models.GetChangesVisitorsCovid(startDate, endDate)
- case utils.DATA_SOURCE_EIA_STEO:
- list, err = models.GetEiaSteoIndex(startDate, endDate)
- case utils.DATA_SOURCE_GIE:
- list, err = models.GetEicIndex(startDate, endDate)
- case utils.DATA_SOURCE_COM_TRADE:
- indexList := make([]*models.ComTradeIndex, 0)
- mappingList := make([]*models.ComTradeCodeMapping, 0)
- indexList, err = models.GetComTradeIndex(startDate, endDate)
- if err != nil {
- return
- }
- mappingList, err = models.GetComTradeCodeMappingList(startDate, endDate)
- if err != nil {
- return
- }
- list = models.ComTradeIndexAndDataResp{
- IndexList: indexList,
- MappingList: mappingList,
- }
- case 61:
- list, err = models.GetMeetingProbabilities(startDate, endDate)
- case utils.DATA_SOURCE_GFEX:
- list, err = models.GetBaseFromTradeGuangzhouIndex(startDate, endDate)
- case utils.DATA_SOURCE_ICPI:
- list, err = models.GetIcpiIndex(startDate, endDate)
- case utils.DATA_SOURCE_USDA_FAS:
- list, err = models.GetUsdaFasIndex(startDate, endDate)
- default:
- }
- return
- }
- func GetIndexDataList(source int, indexCode, startDate, endDate string) (list interface{}, err error) {
- switch source {
- case utils.DATA_SOURCE_EIA_STEO:
- list, err = models.GetEiaSteoIndexData(indexCode, startDate, endDate)
- case utils.DATA_SOURCE_THS:
- list, err = models.GetEdbDataThs(indexCode, startDate, endDate)
- case utils.DATA_SOURCE_PB, utils.DATA_SOURCE_PB_FINANCE:
- list, err = models.GetEdbDataPb(indexCode, startDate, endDate)
- case utils.DATA_SOURCE_GFEX: //广期所
- list, err = models.GetBaseFromTradeGuangzhouData(indexCode, startDate, endDate)
- case utils.DATA_SOURCE_ICPI: //ICPI消费指数
- list, err = models.GetBaseFromIcpiData(indexCode, startDate, endDate)
- case utils.DATA_SOURCE_USDA_FAS:
- list, err = models.GetBaseFromUsdaFasData(indexCode, startDate, endDate)
- default:
- }
- return
- }
- // GetIndexDataPageList 分页获取数据同步
- func GetIndexDataPageList(source, currPage, pageSize int, startDate, endDate string) (list interface{}, err error) {
- switch source {
- case utils.DATA_SOURCE_COM_TRADE:
- var total int
- dataList := make([]*models.ComTradeData, 0)
- total, dataList, err = models.GetComTradeDataList(startDate, endDate, currPage*pageSize, pageSize)
- if err != nil {
- return
- }
- page := paging.GetPaging(currPage, pageSize, total)
- list = models.ComTradeIndexDataResp{
- List: dataList,
- Paging: page,
- }
- case utils.DATA_SOURCE_GFEX: //广期所
- var total int
- dataList := make([]*models.BaseFromTradeGuangzhouData, 0)
- total, dataList, err = models.GetBaseFromTradeGuangzhouDataList(startDate, endDate, currPage*pageSize, pageSize)
- if err != nil {
- return
- }
- page := paging.GetPaging(currPage, pageSize, total)
- list = models.BaseFromTradeGuangzhouDataResp{
- List: dataList,
- Paging: page,
- }
- case utils.DATA_SOURCE_ICPI: //ICPI-消费指数
- var total int
- dataList := make([]*models.BaseFromIcpiData, 0)
- total, dataList, err = models.GetBaseFromIcpiDataList(startDate, endDate, currPage*pageSize, pageSize)
- if err != nil {
- return
- }
- page := paging.GetPaging(currPage, pageSize, total)
- list = models.BaseFromIcpiDataResp{
- List: dataList,
- Paging: page,
- }
- case utils.DATA_SOURCE_USDA_FAS: //美国农业部
- var total int
- dataList := make([]*models.BaseFromUsdaFasData, 0)
- total, dataList, err = models.GetBaseFromUsdaFasDataList(startDate, endDate, currPage*pageSize, pageSize)
- if err != nil {
- return
- }
- page := paging.GetPaging(currPage, pageSize, total)
- list = models.BaseFromUsdaFasDataResp{
- List: dataList,
- Paging: page,
- }
- default:
- }
- return
- }
|