123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- package data_manage
- 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 string `description:"开始日期"`
- EndDate string `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 GetBaseFromUsdaFasIndexMaxDate() (max_date time.Time, err error) {
- o := orm.NewOrm()
- sql := ` SELECT max(a.modify_time)as max_date FROM base_from_usda_fas_data as a `
- err = o.Raw(sql).QueryRow(&max_date)
- return
- }
- type UsdaFasIndexResp struct {
- Ret int
- Msg string
- ErrMsg string
- ErrCode string
- Data []*BaseFromUsdaFasIndex
- }
- func GetBaseFromUsdaFasIndexAll(dateStr string) (list []*BaseFromUsdaFasIndex, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM base_from_usda_fas_index WHERE end_date>=?`
- _, err = o.Raw(sql, dateStr).QueryRows(&list)
- return
- }
- func (obj *BaseFromUsdaFasIndex) AddBaseFromUsdaFasIndex(item *BaseFromUsdaFasIndex) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- func (obj *BaseFromUsdaFasIndex) InsertOrUpdateBaseFromUsdaFasIndex(item *BaseFromUsdaFasIndex) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.InsertOrUpdate(item)
- return
- }
- type UsdaFasClassifyResp struct {
- Ret int
- Msg string
- ErrMsg string
- ErrCode string
- Data []*BaseFromUsdaFasClassify
- }
- func GetBaseFromUsdaFasClassifyAll() (list []*BaseFromUsdaFasClassify, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM base_from_usda_fas_classify `
- _, err = o.Raw(sql).QueryRows(&list)
- return
- }
- func AddBaseFromUsdaFasClassify(item *BaseFromUsdaFasClassify) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- func InsertOrUpdateBaseFromUsdaFasClassify(item *BaseFromUsdaFasClassify) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.InsertOrUpdate(item)
- return
- }
- // GetBaseFromComTradeMaxDate 获取UsdaFas消费者指数最大数据
- func GetBaseFromUsdaFasMaxDate() (max_date time.Time, err error) {
- o := orm.NewOrm()
- sql := ` SELECT max(a.modify_time)as max_date FROM base_from_usda_fas_data as a `
- err = o.Raw(sql).QueryRow(&max_date)
- 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:"修改时间"`
- }
- // GetAllComTradeDataList 获取UsdaFas消费者指数数据
- func GetAllBaseFromUsdaFasDataList(startDate string) (list []*BaseFromUsdaFasData, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM base_from_usda_fas_data WHERE modify_time>=? ORDER BY base_from_usda_fas_data_id ASC `
- _, err = o.Raw(sql, startDate).QueryRows(&list)
- return
- }
- type BaseFromUsdaFasDataResp struct {
- Ret int
- Msg string
- ErrMsg string
- ErrCode string
- Data BaseFromUsdaFasDataIndexAndDataResp
- }
- // ComTradeIndexDataResp 分页列表响应体
- type BaseFromUsdaFasDataIndexAndDataResp struct {
- List []*BaseFromUsdaFasData
- Paging *paging.PagingItem `description:"分页数据"`
- }
- // MultiAddBaseFromComTradeData 批量添加数据
- func MultiAddBaseFromUsdaFasDataIndex(items []*BaseFromUsdaFasData) (lastId int64, err error) {
- num := len(items)
- if num <= 0 {
- return
- }
- o := orm.NewOrm()
- lastId, err = o.InsertMulti(num, items)
- return
- }
|