edb_data_baiinfo.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. package data_manage
  2. import (
  3. "eta/eta_api/global"
  4. "eta/eta_api/utils"
  5. "time"
  6. )
  7. type BaseFromBaiinfoDataSimple struct {
  8. //BaiinfoDataId int `orm:"column(baiinfo_data_id);pk"`
  9. BaiinfoDataId int `gorm:"column:baiinfo_data_id;primaryKey"`
  10. BaseFromBaiinfoIndexId int
  11. IndexCode string
  12. DataTime string
  13. Value string
  14. }
  15. type BaseFromBaiinfoDataDateStruct struct {
  16. MinDate time.Time `gorm:"column:min_date"`
  17. MaxDate time.Time `gorm:"column:max_date"`
  18. }
  19. func GetEdbDataBaiinfoMaxAndMinDate(edbCode string) (min_date, max_date string, err error) {
  20. //o := orm.NewOrmUsingDB("data")
  21. sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date FROM edb_data_baiinfo WHERE edb_code=? `
  22. //err = o.Raw(sql, edbCode).QueryRow(&min_date, &max_date)
  23. var ormItem BaseFromBaiinfoDataDateStruct
  24. err = global.DbMap[utils.DbNameIndex].Raw(sql, edbCode).Scan(&ormItem).Error
  25. if err != nil {
  26. return
  27. }
  28. min_date = ormItem.MinDate.Format(utils.FormatDate)
  29. max_date = ormItem.MaxDate.Format(utils.FormatDate)
  30. return
  31. }