package models import ( "github.com/beego/beego/v2/client/orm" "time" ) //数据录入 type EdbInfo struct { UserId int SecName string `orm:"column(SEC_NAME);" description:"指标名称"` NoticeTime string Frequency string TradeCode string `orm:"column(TRADE_CODE);" description:"指标编码"` } // GetEdbInfoByFrequencyNotDay 获取频度非日度 且 提醒时间不为空 的指标数据 func GetEdbInfoByFrequencyNotDay() (items []*EdbInfo, err error) { sql := `SELECT * FROM edbinfo WHERE frequency!="日度" AND notice_time<>'' and user_id>0 ` o := orm.NewOrmUsingDB("edb") _, err = o.Raw(sql).QueryRows(&items) return } type Edbdata struct { TradeCode string `orm:"column(TRADE_CODE);pk" description:"指标编码"` Dt string `orm:"column(DT)" description:"日期"` Close string `orm:"column(CLOSE)" description:"值"` ModifyTime time.Time `orm:"column(modify_time)" description:"修改时间"` } // GetLastEdbdataInfo 根据指标编号获取指标最近的一条数据 func GetLastEdbdataInfo(tradeCode string) (item *Edbdata, err error) { sql := `SELECT * FROM edbdata WHERE TRADE_CODE=? order by DT desc ` o := orm.NewOrmUsingDB("edb") err = o.Raw(sql, tradeCode).QueryRow(&item) return }