123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package data_manage
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type EdbDataPb struct {
- EdbDataId int `orm:"column(edb_data_id);pk"`
- EdbInfoId int
- EdbCode string
- DataTime string
- Value float64
- Status int
- CreateTime time.Time
- ModifyTime time.Time
- Ticker string
- Field string
- DataTimestamp int64
- }
- func AddEdbDataPb(items []*EdbDataPb) (err error) {
- o := orm.NewOrmUsingDB("data")
- _, err = o.InsertMulti(1, items)
- return
- }
- func ModifyEdbDataPb(edbInfoId int64, edbCode, dataTime string, value float64) (err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` UPDATE edb_data_pb SET edb_info_id=?,value=?,status=1,modify_time=NOW() WHERE edb_code=? AND data_time=? `
- _, err = o.Raw(sql, edbInfoId, value, edbCode, dataTime).Exec()
- return
- }
- func ModifyEdbDataPbStatus(edbInfoId int64, edbCode string) (err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` UPDATE edb_data_pb SET edb_info_id=?, status=1,modify_time=NOW() WHERE edb_code=? `
- _, err = o.Raw(sql, edbInfoId, edbCode).Exec()
- return
- }
- func GetEdbDataPbCount(edbCode, dataTime string) (count int, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT COUNT(1) AS count FROM edb_data_pb WHERE edb_code=? AND data_time=? `
- err = o.Raw(sql, edbCode, dataTime).QueryRow(&count)
- return
- }
- func GetEdbDataPbMaxOrMinDate(edbInfoId int) (min_date, max_date string, err error) {
- o := orm.NewOrmUsingDB("data")
- sql := ` SELECT MIN(data_time) AS min_date,MAX(data_time) AS max_date FROM edb_data_pb WHERE edb_info_id=? `
- err = o.Raw(sql, edbInfoId).QueryRow(&min_date, &max_date)
- return
- }
|