package models 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:"修改时间"` } 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:"修改时间"` } 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:"修改时间"` } func (obj *BaseFromIcpiIndex) GetBaseFromIcpiClassifyAll() (list []*BaseFromIcpiClassify, err error) { o := orm.NewOrm() sql := `SELECT * FROM base_from_icpi_classify ` _, err = o.Raw(sql).QueryRows(&list) return } type BaseFromIcpiDataView 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:"修改时间"` } type BaseFromIcpiIndexView struct { BaseFromIcpiIndexId int `description:"指标id"` BaseFromIcpiClassifyId int `description:"分类id"` IndexCode string `description:"指标编码"` IndexName string `description:"指标名称"` Frequency string `description:"频度"` Unit string `description:"单位"` StartDate string `description:"开始日期"` EndDate string `description:"结束日期"` CreateTime string `description:"创建时间"` ModifyTime string `description:"修改时间"` } func GetIcpiIndex(startDate, endDate string) (items []*BaseFromIcpiIndex, err error) { o := orm.NewOrm() sql := ` SELECT * FROM base_from_icpi_index WHERE end_date >= ? AND end_date <= ? ` _, err = o.Raw(sql, startDate, endDate).QueryRows(&items) return } func GetBaseFromIcpiData(indexCode, startDate, endDate string) (list []*BaseFromIcpiData, err error) { o := orm.NewOrm() sql := `SELECT * FROM base_from_icpi_data WHERE index_code=? AND modify_time>=? AND modify_time<=? ` _, err = o.Raw(sql, indexCode, startDate, endDate).QueryRows(&list) return } // GetComTradeDataList 获取icpi消费指数数据列表 func GetBaseFromIcpiDataList(startDate, endDate string, startSize, pageSize int) (total int, list []*BaseFromIcpiData, err error) { o := orm.NewOrm() totalSql := `SELECT count(1) total FROM base_from_icpi_data WHERE create_time>=? AND create_time<=? ` err = o.Raw(totalSql, startDate, endDate).QueryRow(&total) if err != nil { return } sql := `SELECT * FROM base_from_icpi_data WHERE create_time>=? AND create_time<=? ORDER BY base_from_icpi_data_id ASC LIMIT ?,?` _, err = o.Raw(sql, startDate, endDate, startSize, pageSize).QueryRows(&list) return } // ComTradeIndexDataResp 分页列表响应体 type BaseFromIcpiDataResp struct { List []*BaseFromIcpiData Paging *paging.PagingItem `description:"分页数据"` }