1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "time"
- )
- type BaseFromUsdaFasIndex struct {
- BaseFromUsdaFasIndexId int `orm:"column(base_from_usda_fas_index_id);pk"`
- ClassifyId int
- IndexCode string
- IndexName string
- Frequency string
- Unit string
- Sort int
- StartDate time.Time `description:"开始日期"`
- EndDate time.Time `description:"结束日期"`
- EndValue float64
- Country string `description:"国家"`
- Commodity string `description:"属性"`
- CreateTime time.Time
- ModifyTime time.Time
- }
- // BaseFromUsdaFasClassify UsdaFas原始数据分类表
- type BaseFromUsdaFasClassify struct {
- ClassifyId int `orm:"column(classify_id);pk"`
- ClassifyName string `description:"分类名称"`
- ParentId int `description:"父级id"`
- SysUserId int `description:"创建人id"`
- SysUserRealName string `description:"创建人姓名"`
- Level int `description:"层级"`
- Sort int `description:"排序字段,越小越靠前,默认值:10"`
- ModifyTime time.Time `description:"修改时间"`
- CreateTime time.Time `description:"创建时间"`
- }
- func (obj *BaseFromUsdaFasClassify) GetBaseFromUsdaFasClassifyAll() (list []*BaseFromUsdaFasClassify, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM base_from_usda_fas_classify `
- _, err = o.Raw(sql).QueryRows(&list)
- return
- }
- type BaseFromUsdaFasData struct {
- BaseFromUsdaFasDataId int `orm:"column(base_from_usda_fas_data_id);pk"`
- BaseFromUsdaFasIndexId int `description:"指标id"`
- IndexCode string `description:"指标编码"`
- DataTime string `description:"日期"`
- Value string `description:"值"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"修改时间"`
- }
- func GetUsdaFasIndex(startDate, endDate string) (items []*BaseFromUsdaFasIndex, err error) {
- o := orm.NewOrm()
- sql := ` SELECT * FROM base_from_usda_fas_index WHERE modify_time >= ? AND modify_time <= ? `
- _, err = o.Raw(sql, startDate, endDate).QueryRows(&items)
- return
- }
- func GetBaseFromUsdaFasData(indexCode, startDate, endDate string) (list []*BaseFromUsdaFasData, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM base_from_usda_fas_data WHERE index_code=? AND modify_time>=? AND modify_time<=? `
- _, err = o.Raw(sql, indexCode, startDate, endDate).QueryRows(&list)
- return
- }
- // GetComTradeDataList 获取UsdaFas消费指数数据列表
- func GetBaseFromUsdaFasDataList(startDate, endDate string, startSize, pageSize int) (total int, list []*BaseFromUsdaFasData, err error) {
- o := orm.NewOrm()
- totalSql := `SELECT count(1) total FROM base_from_usda_fas_data WHERE modify_time>=? AND modify_time<=? `
- err = o.Raw(totalSql, startDate, endDate).QueryRow(&total)
- if err != nil {
- return
- }
- sql := `SELECT * FROM base_from_usda_fas_data WHERE modify_time>=? AND modify_time<=? ORDER BY base_from_usda_fas_data_id ASC LIMIT ?,?`
- _, err = o.Raw(sql, startDate, endDate, startSize, pageSize).QueryRows(&list)
- return
- }
- // ComTradeIndexDataResp 分页列表响应体
- type BaseFromUsdaFasDataResp struct {
- List []*BaseFromUsdaFasData
- Paging *paging.PagingItem `description:"分页数据"`
- }
|