index_notice.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package models
  2. import (
  3. "eta_gn/eta_task/global"
  4. "time"
  5. )
  6. //数据录入
  7. type EdbInfo struct {
  8. UserId int
  9. SecName string `orm:"column(SEC_NAME);" description:"指标名称"`
  10. NoticeTime string
  11. Frequency string
  12. TradeCode string `orm:"column(TRADE_CODE);" description:"指标编码"`
  13. }
  14. // GetEdbInfoByFrequencyNotDay 获取频度非日度 且 提醒时间不为空 的指标数据
  15. func GetEdbInfoByFrequencyNotDay() (items []*EdbInfo, err error) {
  16. //sql := `SELECT * FROM edbinfo WHERE frequency!="日度" AND notice_time<>'' and user_id>0 `
  17. //o := orm.NewOrmUsingDB("edb")
  18. //_, err = o.Raw(sql).QueryRows(&items)
  19. sql := `SELECT * FROM edbinfo WHERE frequency!="日度" AND notice_time<>'' and user_id>0 `
  20. err = global.DmSQL["edb"].Raw(sql).Find(&items).Error
  21. return
  22. }
  23. type Edbdata struct {
  24. TradeCode string `gorm:"column:TRADE_CODE;primaryKey"` // `orm:"column(TRADE_CODE);pk" description:"指标编码"`
  25. Dt string `orm:"column(DT)" description:"日期"`
  26. Close string `orm:"column(CLOSE)" description:"值"`
  27. ModifyTime time.Time `orm:"column(modify_time)" description:"修改时间"`
  28. }
  29. // GetLastEdbdataInfo 根据指标编号获取指标最近的一条数据
  30. func GetLastEdbdataInfo(tradeCode string) (item *Edbdata, err error) {
  31. //sql := `SELECT * FROM edbdata WHERE TRADE_CODE=? order by DT desc `
  32. //o := orm.NewOrmUsingDB("edb")
  33. //err = o.Raw(sql, tradeCode).QueryRow(&item)
  34. sql := `SELECT * FROM edbdata WHERE TRADE_CODE=? order by DT desc `
  35. err = global.DmSQL["data"].Raw(sql, tradeCode).Find(&item).Error
  36. return
  37. }