package models import ( "github.com/beego/beego/v2/client/orm" "time" ) type BaseFromTradeEicIndex struct { BaseFromEicIndexId int `orm:"column(base_from_eic_index_id);pk"` Country string Type string EicCode string ShortName string Name string Status string GasDayStartedOn string GasInStorage float64 GasInStorageCode 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 CreateTime time.Time ModifyTime time.Time } type BaseFromTradeMapping struct { BaseFromTradeMappingId int `orm:"column(base_from_trade_mapping_id);pk"` IndexName string IndexCode string Exchange string } func AddBaseFromEicIndex(item *BaseFromTradeEicIndex) (lastId int64, err error) { o := orm.NewOrmUsingDB("data") lastId, err = o.Insert(item) return } func GetSSOFromEicIndexAll(name string) (list []*BaseFromTradeEicIndex, err error) { o := orm.NewOrmUsingDB("data") sql := `SELECT * FROM base_from_trade_eic_index where name=? and type='SSO'` _, err = o.Raw(sql, name).QueryRows(&list) return } func GetFacFromEicIndexAll(name string) (list []*BaseFromTradeEicIndex, err error) { o := orm.NewOrmUsingDB("data") sql := `SELECT * FROM base_from_trade_eic_index where name=? and type='Storage Facility'` _, err = o.Raw(sql, name).QueryRows(&list) return } func ModifyBaseFromEicIndex(gasInStorage, full, trend, injection, withdrawal float64, dataId int) (err error) { o := orm.NewOrmUsingDB("data") sql := `UPDATE base_from_trade_eic_index 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 GetCountryFromEicIndexAll(name string) (list []*BaseFromTradeEicIndex, err error) { o := orm.NewOrmUsingDB("data") sql := `SELECT * FROM base_from_trade_eic_index where country=? and (type='country' or type='continent')` _, err = o.Raw(sql, name).QueryRows(&list) return } func AddEicDataMulti(items []*BaseFromTradeEicIndex) (successNums int64, err error) { o := orm.NewOrmUsingDB("data") successNums, err = o.InsertMulti(1, items) return } func AddEicCodeMulti(items []*BaseFromTradeMapping) (successNums int64, err error) { o := orm.NewOrmUsingDB("data") successNums, err = o.InsertMulti(1, items) return }