1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "time"
- )
- type BaseFromTradeGuangzhouIndex struct {
- BaseFromTradeGuangzhouIndexId int `orm:"column(base_from_trade_guangzhou_index_id);pk"`
- BaseFromTradeGuangzhouClassifyId int `description:"分类id"`
- BaseFromTradeGuangzhouContractId int `description:"合约id"`
- IndexCode string `description:"指标编码"`
- IndexName string `description:"指标名称"`
- Frequency string `description:"频率"`
- Unit string `description:"单位"`
- StartDate string `description:"开始日期"`
- EndDate string `description:"结束日期"`
- CreateTime time.Time `description:"创建日期"`
- ModifyTime time.Time `description:"修改日期"`
- Value float64 `description:"数据值"`
- }
- type BaseFromTradeGuangzhouClassify struct {
- BaseFromTradeGuangzhouClassifyId int `orm:"column(base_from_trade_guangzhou_classify_id);pk"`
- ClassifyName string `description:"分类名称"`
- ClassifyCode string `description:"分类编码"`
- ParentId int `description:"分类父级id"`
- ModifyTime time.Time `description:"修改时间"`
- CreateTime time.Time `description:"创建时间"`
- }
- type BaseFromTradeGuangzhouData struct {
- BaseFromTradeGuangzhouDataId int `orm:"column(base_from_trade_guangzhou_data_id);pk"`
- BaseFromTradeGuangzhouIndexId int `description:"指标id"`
- IndexCode string `description:"指标编码"`
- DataTime string `description:"数据日期"`
- Value float64 `description:"数据值"`
- QtySub float64 `description:"增减"`
- CreateTime time.Time `description:"创建日期"`
- ModifyTime time.Time `description:"修改日期"`
- }
- func GetBaseFromTradeGuangzhouData(indexCode, startDate, endDate string) (list []*BaseFromTradeGuangzhouData, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM base_from_trade_guangzhou_data WHERE index_code=? AND create_time>=? AND create_time<=? `
- _, err = o.Raw(sql, indexCode, startDate, endDate).QueryRows(&list)
- return
- }
- // GetComTradeDataList 获取联合国商品贸易数据列表
- func GetBaseFromTradeGuangzhouDataList(startDate, endDate string, startSize, pageSize int) (total int, list []*BaseFromTradeGuangzhouData, err error) {
- o := orm.NewOrm()
- totalSql := `SELECT count(1) total FROM base_from_trade_guangzhou_data WHERE create_time>=? AND create_time<=? `
- err = o.Raw(totalSql, startDate, endDate).QueryRow(&total)
- if err != nil {
- return
- }
- sql := `SELECT * FROM base_from_trade_guangzhou_data WHERE create_time>=? AND create_time<=? ORDER BY base_from_trade_guangzhou_data_id ASC LIMIT ?,?`
- _, err = o.Raw(sql, startDate, endDate, startSize, pageSize).QueryRows(&list)
- return
- }
- // ComTradeIndexDataResp 分页列表响应体
- type BaseFromTradeGuangzhouDataResp struct {
- List []*BaseFromTradeGuangzhouData
- Paging *paging.PagingItem `description:"分页数据"`
- }
- func GetBaseFromTradeGuangzhouIndex(startDate, endDate string) (list []*BaseFromTradeGuangzhouIndex, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM base_from_trade_guangzhou_index WHERE modify_time>=? AND modify_time<=? `
- _, err = o.Raw(sql, startDate, endDate).QueryRows(&list)
- return
- }
|