edb_data_icpi.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package data_manage
  2. import (
  3. "eta/eta_api/global"
  4. "eta/eta_api/utils"
  5. "fmt"
  6. )
  7. type IcpiData struct {
  8. InputValue string `orm:"column(DATA_VALUE)" description:"日期"`
  9. DataTime string `orm:"column(DATA_DATE)" description:"值"`
  10. }
  11. func GetEdbDataIcpiMaxOrMinDate(edbCode string) (minDate, maxDate string, err error) {
  12. //o := orm.NewOrmUsingDB("data")
  13. sql := ` SELECT MIN(data_time) AS minDate,MAX(data_time) AS maxDate FROM edb_data_icpi WHERE edb_code=? `
  14. //err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
  15. var maxAndMinDate MaxAndMinDate
  16. err = global.DbMap[utils.DbNameIndex].Raw(sql, edbCode).First(&maxAndMinDate).Error
  17. if err != nil {
  18. return
  19. }
  20. minDate = maxAndMinDate.MinDate.Format(utils.FormatDate)
  21. maxDate = maxAndMinDate.MaxDate.Format(utils.FormatDate)
  22. return
  23. }
  24. type IcpiIndexView struct {
  25. BaseFromTradeGuangzhouIndexId int `description:"指标id"`
  26. BaseFromTradeGuangzhouClassifyId int `description:"分类id"`
  27. IndexCode string `description:"指标编码"`
  28. IndexName string `description:"指标名称"`
  29. Frequency string `description:"频率"`
  30. Unit string `description:"单位"`
  31. StartDate string `description:"开始日期"`
  32. EndDate string `description:"结束日期"`
  33. Value float64 `description:"数据"`
  34. }
  35. // GetBaseInfoFromShByIndexCode 获取指标信息
  36. func GetBaseInfoFromIcpiByIndexCode(indexCode string) (item *IcpiIndexView, err error) {
  37. //o := orm.NewOrmUsingDB("data")
  38. sql := `SELECT * FROM base_from_icpi_index WHERE index_code=? `
  39. sql = fmt.Sprintf(sql)
  40. //err = o.Raw(sql, indexCode).QueryRow(&item)
  41. err = global.DbMap[utils.DbNameIndex].Raw(sql, indexCode).First(&item).Error
  42. return
  43. }