123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- package data_manage
- import (
- "eta/eta_task/utils"
- "time"
- "github.com/beego/beego/v2/client/orm"
- )
- // 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
- }
- func GetBaseFromEiaSteoIndexCodeListByDate(dateStr string) (list []string, err error) {
- o := orm.NewOrm()
- sql := `SELECT index_code FROM base_from_eia_steo_index WHERE modify_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:"分类名称(原始名称)"`
- ParentId int `description:"父级id"`
- Level int `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 (b *BaseFromEiaSteoData) Update(cols []string) (err error) {
- o := orm.NewOrm()
- _, err = o.Update(b, cols...)
- return
- }
- 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
- }
- func AddBaseEiaSteoClassify(item *BaseFromEiaSteoClassify) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- func (item *BaseFromEiaSteoClassify) Update(cols []string) (err error) {
- o := orm.NewOrm()
- _, err = o.Update(item, cols...)
- return
- }
- func BatchDeleteBaseFromEiaSteoClassify(id []int) (err error) {
- if len(id) == 0 {
- return
- }
- o := orm.NewOrm()
- sql := `DELETE FROM base_from_eia_steo_classify WHERE base_from_eia_steo_classify_id IN (` + utils.GetOrmInReplace(len(id)) + `)`
- _, err = o.Raw(sql, id).Exec()
- 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
- }
- type EiaSteoClassifyDataResp struct {
- Ret int
- Msg string
- ErrMsg string
- ErrCode string
- Data []*BaseFromEiaSteoClassify
- }
- 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 GetBaseFromEiaSteoIndexDataByIndexCode(indexCode, dateStr string) (list []*BaseFromEiaSteoData, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM base_from_eia_steo_data WHERE index_code=? AND modify_time>=?`
- _, err = o.Raw(sql, indexCode, dateStr).QueryRows(&list)
- return
- }
- func GetBaseFromEiaSteoIndexDataByDate(dateStr string) (list []*BaseFromEiaSteoData, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM base_from_eia_steo_data WHERE modify_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
- }
- func GetBaseFromEiaSteoIndexMaxCreateDate() (max_date time.Time, err error) {
- o := orm.NewOrm()
- sql := ` SELECT max(a.create_time)as max_date FROM base_from_eia_steo_index as a `
- err = o.Raw(sql).QueryRow(&max_date)
- return
- }
|