package data_manage import ( "github.com/beego/beego/v2/client/orm" "github.com/rdlucklib/rdluck_tools/paging" "time" ) type BaseFromIcpiIndex struct { BaseFromIcpiIndexId int `orm:"column(base_from_icpi_index_id);pk"` BaseFromIcpiClassifyId int `description:"分类id"` IndexCode string `description:"指标编码"` IndexName string `description:"指标名称"` Frequency string `description:"频度"` StartDate time.Time `description:"开始日期"` EndDate time.Time `description:"结束日期"` CreateTime time.Time `description:"创建时间"` ModifyTime time.Time `description:"修改时间"` } func GetBaseFromIcpiIndexMaxDate() (max_date time.Time, err error) { o := orm.NewOrm() sql := ` SELECT max(a.data_time)as max_date FROM base_from_icpi_data as a ` err = o.Raw(sql).QueryRow(&max_date) return } type IcpiIndexResp struct { Ret int Msg string ErrMsg string ErrCode string Data []*BaseFromIcpiIndex } func GetBaseFromIcpiIndexAll(dateStr string) (list []*BaseFromIcpiIndex, err error) { o := orm.NewOrm() sql := `SELECT * FROM base_from_icpi_index WHERE end_date>=?` _, err = o.Raw(sql, dateStr).QueryRows(&list) return } func (obj *BaseFromIcpiIndex) AddBaseFromIcpiIndex(item *BaseFromIcpiIndex) (lastId int64, err error) { o := orm.NewOrm() lastId, err = o.Insert(item) return } func (obj *BaseFromIcpiIndex) InsertOrUpdateBaseFromIcpiIndex(item *BaseFromIcpiIndex) (lastId int64, err error) { o := orm.NewOrm() lastId, err = o.InsertOrUpdate(item) return } type BaseFromIcpiClassify struct { BaseFromIcpiClassifyId int `orm:"column(base_from_icpi_classify_id);pk"` ClassifyName string `description:"分类名称"` ClassifyNameEn string `description:"英文名称"` ParentId int `description:"上级id"` CreateTime string `description:"创建时间"` ModifyTime string `description:"修改时间"` } type IcpiClassifyResp struct { Ret int Msg string ErrMsg string ErrCode string Data []*BaseFromIcpiClassify } func GetBaseFromIcpiClassifyAll() (list []*BaseFromIcpiClassify, err error) { o := orm.NewOrm() sql := `SELECT * FROM base_from_icpi_classify ` _, err = o.Raw(sql).QueryRows(&list) return } func AddBaseFromIcpiClassify(item *BaseFromIcpiClassify) (lastId int64, err error) { o := orm.NewOrm() lastId, err = o.Insert(item) return } func InsertOrUpdateBaseFromIcpiClassify(item *BaseFromIcpiClassify) (lastId int64, err error) { o := orm.NewOrm() lastId, err = o.InsertOrUpdate(item) return } // GetBaseFromComTradeMaxDate 获取ICPI消费者指数最大数据 func GetBaseFromIcpiMaxDate() (max_date time.Time, err error) { o := orm.NewOrm() sql := ` SELECT max(a.create_time)as max_date FROM base_from_icpi_data as a ` err = o.Raw(sql).QueryRow(&max_date) return } type BaseFromIcpiData struct { BaseFromIcpiDataId int `orm:"column(base_from_icpi_data_id);pk"` BaseFromIcpiIndexId int `description:"指标id"` IndexCode string `description:"指标编码"` DataTime string `description:"日期"` Value string `description:"值"` CreateTime time.Time `description:"创建时间"` ModifyTime time.Time `description:"修改时间"` } // GetAllComTradeDataList 获取ICPI消费者指数数据 func GetAllBaseFromIcpiDataList(startDate string) (list []*BaseFromIcpiData, err error) { o := orm.NewOrm() sql := `SELECT * FROM base_from_icpi_data WHERE create_time>=? ORDER BY base_from_icpi_data_id ASC ` _, err = o.Raw(sql, startDate).QueryRows(&list) return } type BaseFromIcpiDataResp struct { Ret int Msg string ErrMsg string ErrCode string Data BaseFromIcpiDataIndexAndDataResp } // ComTradeIndexDataResp 分页列表响应体 type BaseFromIcpiDataIndexAndDataResp struct { List []*BaseFromIcpiData Paging *paging.PagingItem `description:"分页数据"` } // MultiAddBaseFromComTradeData 批量添加数据 func MultiAddBaseFromIcpiDataIndex(items []*BaseFromIcpiData) (lastId int64, err error) { num := len(items) if num <= 0 { return } o := orm.NewOrm() lastId, err = o.InsertMulti(num, items) return }