1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- package data_manage
- import (
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "time"
- )
- // ComTradeIndex 联合国商品贸易数据指标表
- type ComTradeIndex struct {
- ComTradeId int `orm:"column(com_trade_id);pk"`
- IndexCode string `description:"联合国商品贸易编码"`
- IndexName string `description:"联合国商品名称"`
- IndexNameCn string `description:"联合国商品名称(中文)"`
- UpdateTime time.Time `description:"数据最近更新时间"`
- CreateTime time.Time `description:"创建时间"`
- }
- // GetAllComTradeIndexList 获取指标数据列表
- func GetAllComTradeIndexList(startDate string) (list []*ComTradeIndex, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM com_trade_index WHERE create_time>=? ORDER BY com_trade_id DESC `
- _, err = o.Raw(sql, startDate).QueryRows(&list)
- return
- }
- func GetBaseFromComTradeCodeMappingAll(dateStr string) (list []*BaseFromEiaSteoIndex, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM com_trade_index WHERE create_time>=?`
- _, err = o.Raw(sql, dateStr).QueryRows(&list)
- return
- }
- // AddBaseFromComTradeIndex 添加新的指标
- func AddBaseFromComTradeIndex(item *ComTradeIndex) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- // ComTradeCodeMapping 联合国商品贸易数据指标编码与分类编码的关系表
- type ComTradeCodeMapping struct {
- Code string `orm:"column(code);pk"`
- IndexCode string `description:"联合国商品贸易编码"`
- Type int `description:"1:价格;2:重量"`
- Name string `description:"指标名称"`
- CreateTime time.Time `description:"创建时间"`
- }
- // GetAllComTradeCodeMappingList 获取联合国商品贸易数据指标编码与分类编码的关系列表
- func GetAllComTradeCodeMappingList(startDate string) (list []*ComTradeCodeMapping, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM com_trade_code_mapping WHERE create_time>=? ORDER BY create_time ASC `
- _, err = o.Raw(sql, startDate).QueryRows(&list)
- return
- }
- // AddBaseFromComTradeCodeMapping 添加联合国商品贸易数据指标编码与分类编码的关系
- func AddBaseFromComTradeCodeMapping(item *ComTradeCodeMapping) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- type ComTradeIndexMappingResp struct {
- Ret int
- Msg string
- ErrMsg string
- ErrCode string
- Data ComTradeIndexAndMappingResp
- }
- type ComTradeIndexAndMappingResp struct {
- IndexList []ComTradeIndex
- MappingList []ComTradeCodeMapping
- }
- type ComTradeIndexDataResp struct {
- Ret int
- Msg string
- ErrMsg string
- ErrCode string
- Data ComTradeIndexAndDataResp
- }
- // ComTradeIndexAndDataResp 指标数据结构体
- type ComTradeIndexAndDataResp struct {
- List []*ComTradeData
- Paging *paging.PagingItem `description:"分页数据"`
- }
|