123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- package data_manage
- import (
- "eta_gn/eta_task/global"
- "eta_gn/eta_task/utils"
- "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)
- err = global.DEFAULT_DmSQL.Raw(sql).Scan(&max_date).Error
- 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)
- err = global.DEFAULT_DmSQL.Raw(sql, dateStr).Find(&list).Error
- return
- }
- func (obj *BaseFromIcpiIndex) AddBaseFromIcpiIndex(item *BaseFromIcpiIndex) (lastId int64, err error) {
- //o := orm.NewOrm()
- //lastId, err = o.Insert(item)
- err = global.DEFAULT_DmSQL.Create(item).Error
- if err != nil {
- return
- }
- lastId = int64(item.BaseFromIcpiIndexId)
- return
- }
- func (obj *BaseFromIcpiIndex) InsertOrUpdateBaseFromIcpiIndex(item *BaseFromIcpiIndex) (lastId int64, err error) {
- //o := orm.NewOrm()
- //lastId, err = o.InsertOrUpdate(item)
- err = global.DEFAULT_DmSQL.Create(item).Error
- if err != nil {
- return
- }
- lastId = int64(item.BaseFromIcpiIndexId)
- 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)
- err = global.DEFAULT_DmSQL.Raw(sql).Find(&list).Error
- return
- }
- func AddBaseFromIcpiClassify(item *BaseFromIcpiClassify) (lastId int64, err error) {
- //o := orm.NewOrm()
- //lastId, err = o.Insert(item)
- err = global.DEFAULT_DmSQL.Create(item).Error
- if err != nil {
- return
- }
- lastId = int64(item.BaseFromIcpiClassifyId)
- return
- }
- func InsertOrUpdateBaseFromIcpiClassify(item *BaseFromIcpiClassify) (lastId int64, err error) {
- //o := orm.NewOrm()
- //lastId, err = o.InsertOrUpdate(item)
- err = global.DEFAULT_DmSQL.Create(item).Error
- if err != nil {
- return
- }
- lastId = int64(item.BaseFromIcpiClassifyId)
- 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)
- err = global.DEFAULT_DmSQL.Raw(sql).Scan(&max_date).Error
- 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)
- err = global.DEFAULT_DmSQL.Raw(sql, startDate).Find(&list).Error
- 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)
- err = global.DEFAULT_DmSQL.CreateInBatches(items, utils.MultiAddNum).Error
- return
- }
|