edb_data_manual.go 1.1 KB

123456789101112131415161718192021222324252627282930
  1. package data_manage
  2. import (
  3. "eta/eta_api/global"
  4. "eta/eta_api/utils"
  5. "time"
  6. )
  7. func GetEdbDataManualMaxOrMinDate(edbCode string) (min_date, max_date string, err error) {
  8. //o := orm.NewOrmUsingDB("data")
  9. //sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date FROM edb_data_manual WHERE edb_code=? `
  10. //err = o.Raw(sql, edbCode).QueryRow(&min_date, &max_date)
  11. sql := ` SELECT MIN(data_time) AS minDate,MAX(data_time) AS maxDate FROM edb_data_manual WHERE edb_code=? `
  12. var maxAndMinDate MaxAndMinDate
  13. err = global.DbMap[utils.DbNameIndex].Raw(sql, edbCode).First(&maxAndMinDate).Error
  14. if err != nil {
  15. return
  16. }
  17. min_date = maxAndMinDate.MinDate.Format(utils.FormatDate)
  18. max_date = maxAndMinDate.MaxDate.Format(utils.FormatDate)
  19. return
  20. }
  21. type ManualEdbdata struct {
  22. TradeCode string `gorm:"column:TRADE_CODE;primaryKey" description:"指标编码"`
  23. //TradeCode string `orm:"column(TRADE_CODE);pk" description:"指标编码"`
  24. Dt string `orm:"column(DT)" description:"日期"`
  25. Close string `orm:"column(CLOSE)" description:"值"`
  26. ModifyTime time.Time `orm:"column(modify_time)" description:"修改时间"`
  27. }