edb_data_icpi.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package data_manage
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. )
  6. type IcpiData struct {
  7. InputValue string `orm:"column(DATA_VALUE)" description:"日期"`
  8. DataTime string `orm:"column(DATA_DATE)" description:"值"`
  9. }
  10. func GetEdbDataIcpiMaxOrMinDate(edbCode string) (minDate, maxDate string, err error) {
  11. o := orm.NewOrmUsingDB("data")
  12. sql := ` SELECT MIN(data_time) AS minDate,MAX(data_time) AS maxDate FROM edb_data_icpi WHERE edb_code=? `
  13. err = o.Raw(sql, edbCode).QueryRow(&minDate, &maxDate)
  14. return
  15. }
  16. type IcpiIndexView struct {
  17. BaseFromTradeGuangzhouIndexId int `description:"指标id"`
  18. BaseFromTradeGuangzhouClassifyId int `description:"分类id"`
  19. IndexCode string `description:"指标编码"`
  20. IndexName string `description:"指标名称"`
  21. Frequency string `description:"频率"`
  22. Unit string `description:"单位"`
  23. StartDate string `description:"开始日期"`
  24. EndDate string `description:"结束日期"`
  25. Value float64 `description:"数据"`
  26. }
  27. // GetBaseInfoFromShByIndexCode 获取指标信息
  28. func GetBaseInfoFromIcpiByIndexCode(indexCode string) (item *IcpiIndexView, err error) {
  29. o := orm.NewOrmUsingDB("data")
  30. sql := `SELECT * FROM base_from_icpi_index WHERE index_code=? `
  31. sql = fmt.Sprintf(sql)
  32. err = o.Raw(sql, indexCode).QueryRow(&item)
  33. return
  34. }