package data_manage

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           string
	GasInStorageCode       string
	Consumption            string
	ConsumptionCode        string
	ConsumptionFull        string
	ConsumptionFullCode    string
	Full                   string
	FullCode               string
	Trend                  string
	TrendCode              string
	Injection              string
	InjectionCode          string
	Withdrawal             string
	WithdrawalCode         string
	WorkingGasVolume       string
	WorkingGasVolumeCode   string
	InjectionCapacity      string
	InjectionCapacityCode  string
	WithdrawalCapacity     string
	WithdrawalCapacityCode string
	Info                   string
	Parent                 string
	CreateTime             time.Time
	ModifyTime             time.Time
}


func GetBaseFromEicIndexMaxDate() (max_date time.Time, err error) {
	o := orm.NewOrm()
	sql := ` SELECT max(a.gas_day_start)as max_date FROM base_from_trade_eic_index_v2 as a `
	err = o.Raw(sql).QueryRow(&max_date)
	return
}

func GetBaseFromEicIndexAll(dateStr string) (list []*BaseFromTradeEicIndexV2, err error) {
	o := orm.NewOrm()
	sql := `SELECT * FROM base_from_trade_eic_index_v2 where gas_day_start >=?`
	_, err = o.Raw(sql, dateStr).QueryRows(&list)
	return
}

func AddBaseFromEicIndexV2(item *BaseFromTradeEicIndexV2) (lastId int64, err error) {
	o := orm.NewOrm()
	lastId, err = o.Insert(item)
	return
}

type EicIndexResp struct {
	Ret     int
	Msg     string
	ErrMsg  string
	ErrCode string
	Data    []*BaseFromTradeEicIndexV2
}