package models import ( "github.com/beego/beego/v2/client/orm" "time" ) type BaseFromTradeEicIndexV2 struct { BaseFromEicIndexId int `orm:"column(base_from_eic_index_id);pk"` Type string EicCode string Name string Status string GasDayStart string GasInStorage float64 GasInStorageCode string Consumption string ConsumptionCode string ConsumptionFull string ConsumptionFullCode string Full float64 FullCode string Trend float64 TrendCode string Injection float64 InjectionCode string Withdrawal float64 WithdrawalCode string WorkingGasVolume float64 WorkingGasVolumeCode string InjectionCapacity float64 InjectionCapacityCode string WithdrawalCapacity float64 WithdrawalCapacityCode string Info string Parent string CreateTime time.Time ModifyTime time.Time } func AddBaseFromEicIndexV2(item *BaseFromTradeEicIndexV2) (lastId int64, err error) { o := orm.NewOrmUsingDB("data") lastId, err = o.Insert(item) return } func GetSSOFromEicIndexAllV2(date string) (list []*BaseFromTradeEicIndexV2, err error) { o := orm.NewOrmUsingDB("data") sql := `SELECT * FROM base_from_trade_eic_index_v2 where gas_day_start=? and type='sso'` _, err = o.Raw(sql, date).QueryRows(&list) return } func GetFacFromEicIndexAllV2(date string) (list []*BaseFromTradeEicIndexV2, err error) { o := orm.NewOrmUsingDB("data") sql := `SELECT * FROM base_from_trade_eic_index_v2 where gas_day_start=? and type='fac'` _, err = o.Raw(sql, date).QueryRows(&list) return } func ModifyBaseFromEicIndexV2(gasInStorage, full, trend, injection, withdrawal float64, dataId int) (err error) { o := orm.NewOrmUsingDB("data") sql := `UPDATE base_from_trade_eic_index_v2 SET gas_in_storage=?,full=?,trend=?,injection=?,withdrawal=?,modify_time=NOW() WHERE base_from_eic_index_id=? ` _, err = o.Raw(sql, gasInStorage, full, trend, injection, withdrawal, dataId).Exec() return } func GetCountryFromEicIndexAllV2(date string) (list []*BaseFromTradeEicIndexV2, err error) { o := orm.NewOrmUsingDB("data") sql := `SELECT * FROM base_from_trade_eic_index_v2 where gas_day_start=? and type='country' ` _, err = o.Raw(sql, date).QueryRows(&list) return } func GetContinentFromEicIndexAllV2(date string) (list []*BaseFromTradeEicIndexV2, err error) { o := orm.NewOrmUsingDB("data") sql := `SELECT * FROM base_from_trade_eic_index_v2 where gas_day_start=? and type='continent' ` _, err = o.Raw(sql, date).QueryRows(&list) return } func AddEicDataMultiV2(items []*BaseFromTradeEicIndexV2) (successNums int64, err error) { o := orm.NewOrmUsingDB("data") successNums, err = o.InsertMulti(1, items) return }