123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- package data_manage
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- // BaseFromEiaSteoIndex EiaSteo指标
- type BaseFromEiaSteoIndex struct {
- BaseFromEiaSteoIndexId int `orm:"column(base_from_eia_steo_index_id);pk"`
- BaseFromEiaSteoClassifyId int `description:"指标分类id"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称(中文名称)"`
- IndexNameOriginal string `description:"指标名称(原始名称)"`
- Frequency string `description:"频度"`
- Level int `description:"指标层级(原始层级)"`
- Unit string `description:"单位"`
- Super string `description:"我也不知道是个啥,反正先存起来,万一用到了呢"`
- Precision int `description:"精度,我也不知道会不会用到,反正先存起来,万一用到了呢"`
- LastHistorical string `description:"最近的历史记录,我也不知道会不会用到,反正先存起来,万一用到了呢"`
- Description string `description:"备注信息,我也不知道会不会用到,反正先存起来,万一用到了呢"`
- IsMappable int `description:"是否可映射,我也不知道会不会用到,反正先存起来,万一用到了呢"`
- StartDate string `description:"开始日期"`
- EndDate string `description:"结束日期"`
- ModifyTime string `description:"最新更新时间"`
- CreateTime string `description:"创建时间"`
- }
- func AddBaseFromEiaSteoIndex(item *BaseFromEiaSteoIndex) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- func InsertOrUpdateBaseFromEiaSteoIndex(item *BaseFromEiaSteoIndex) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.InsertOrUpdate(item)
- return
- }
- // Add 新增指标
- func (item *BaseFromEiaSteoIndex) Add() (err error) {
- o := orm.NewOrm()
- lastId, err := o.Insert(item)
- if err != nil {
- return
- }
- item.BaseFromEiaSteoIndexId = int(lastId)
- return
- }
- func GetBaseFromEiaSteoIndexAll(dateStr string) (list []*BaseFromEiaSteoIndex, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM base_from_eia_steo_index WHERE create_time>=?`
- _, err = o.Raw(sql, dateStr).QueryRows(&list)
- return
- }
- // Update 更新作者基础信息
- func (item *BaseFromEiaSteoIndex) Update(cols []string) (err error) {
- o := orm.NewOrm()
- _, err = o.Update(item, cols...)
- return
- }
- // BaseFromEiaSteoClassify EiaSteo分类
- type BaseFromEiaSteoClassify struct {
- BaseFromEiaSteoClassifyId int `orm:"column(base_from_eia_steo_classify_id);pk"`
- ClassifyName string `description:"分类名称(中文名称)"`
- ClassifyNameOriginal string `description:"分类名称(原始名称)"`
- ModifyTime time.Time `description:"最新更新时间"`
- CreateTime time.Time `description:"创建时间"`
- }
- // 新增分类
- func (item *BaseFromEiaSteoClassify) AddBaseFromEiaSteoClassify() (err error) {
- o := orm.NewOrm()
- lastId, err := o.Insert(item)
- if err != nil {
- return
- }
- item.BaseFromEiaSteoClassifyId = int(lastId)
- return
- }
- // BaseFromEiaSteoData EiaSteo数据表
- type BaseFromEiaSteoData struct {
- BaseFromEiaSteoDataId int `orm:"column(base_from_eia_steo_data_id);pk"`
- BaseFromEiaSteoIndexId int `description:"指标id"`
- IndexCode string `description:"指标编码"`
- DataTime time.Time `description:"数据日期"`
- Value float64 `description:"数据值"`
- ModifyTime time.Time `description:"最新更新时间"`
- CreateTime time.Time `description:"创建时间"`
- }
- func AddBaseFromEiaSteoData(item *BaseFromEiaSteoData) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- // GetBaseFromEiaSteoClassifyAll 获取所有的分类
- func GetBaseFromEiaSteoClassifyAll() (list []*BaseFromEiaSteoClassify, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM base_from_eia_steo_classify`
- _, err = o.Raw(sql).QueryRows(&list)
- return
- }
- type EiaSteoIndexResp struct {
- Ret int
- Msg string
- ErrMsg string
- ErrCode string
- Data []*BaseFromEiaSteoIndex
- }
- type EiaSteoIndexDataResp struct {
- Ret int
- Msg string
- ErrMsg string
- ErrCode string
- Data []*BaseFromEiaSteoData
- }
- func GetBaseFromEiaSteoIndexDataAll(dateStr string) (list []*BaseFromEiaSteoData, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM base_from_eia_steo_data WHERE create_time>=?`
- _, err = o.Raw(sql, dateStr).QueryRows(&list)
- return
- }
- func GetBaseFromEiaSteoIndexMaxDate() (max_date time.Time, err error) {
- o := orm.NewOrm()
- sql := ` SELECT max(a.data_time)as max_date FROM base_from_eia_steo_data as a `
- err = o.Raw(sql).QueryRow(&max_date)
- return
- }
|