123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- package data_manage
- 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:"数据值"`
- }
- func AddBaseFromTradeGuangzhouIndex(item *BaseFromTradeGuangzhouIndex) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.InsertOrUpdate(item)
- return
- }
- func GetBaseFromTradeGuangzhouIndexAll() (list []*BaseFromTradeGuangzhouIndex, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM base_from_trade_guangzhou_index `
- _, err = o.Raw(sql).QueryRows(&list)
- return
- }
- type GuangzhouIndexResp struct {
- Ret int
- Msg string
- ErrMsg string
- ErrCode string
- Data []*BaseFromTradeGuangzhouIndex
- }
- 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 GuangzhouClassifyResp struct {
- Ret int
- Msg string
- ErrMsg string
- ErrCode string
- Data []*BaseFromTradeGuangzhouClassify
- }
- func GetBaseFromTradeGuangzhouClassifyAll() (list []*BaseFromTradeGuangzhouClassify, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM base_from_trade_guangzhou_classify `
- _, err = o.Raw(sql).QueryRows(&list)
- return
- }
- func AddBaseFromTradeGuangzhouClassify(item *BaseFromTradeGuangzhouClassify) (lastId int64, err error) {
- o := orm.NewOrm()
- lastId, err = o.Insert(item)
- return
- }
- type BaseFromTradeGuangzhouContract struct {
- BaseFromTradeGuangzhouContractId int `orm:"column(base_from_trade_guangzhou_contract_id);pk"`
- BaseFromTradeGuangzhouClassifyId int `description:"分类id"`
- ClassifyCode string `description:"分类编码"`
- Contract string `description:"合约编码"`
- TradeDate string `description:"合约日期"`
- }
- // 新增合约
- func (obj *BaseFromTradeGuangzhouIndex) AddBaseFromTradeGuangzhouContract(item *BaseFromTradeGuangzhouContract) (err error) {
- o := orm.NewOrmUsingDB("data")
- _, err = o.Insert(item)
- return
- }
- type GuangzhouContractResp struct {
- Ret int
- Msg string
- ErrMsg string
- ErrCode string
- Data []*BaseFromTradeGuangzhouContract
- }
- func GetBaseFromTradeGuangzhouContractAll() (list []*BaseFromTradeGuangzhouContract, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM base_from_trade_guangzhou_contract `
- _, err = o.Raw(sql).QueryRows(&list)
- return
- }
- // GetBaseFromComTradeMaxDate 获取广州期货交易所最大数据
- func GetBaseFromTradeGuangzhouMaxDate() (max_date time.Time, err error) {
- o := orm.NewOrm()
- sql := ` SELECT max(a.create_time)as max_date FROM base_from_trade_guangzhou_data as a `
- err = o.Raw(sql).QueryRow(&max_date)
- return
- }
- 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:"修改日期"`
- }
- // GetAllComTradeDataList 获取广州期货交易所数据
- func GetAllBaseFromTradeGuangzhouDataList(startDate string) (list []*BaseFromTradeGuangzhouData, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM base_from_trade_guangzhou_data WHERE create_time>=? ORDER BY base_from_trade_guangzhou_data_id ASC `
- _, err = o.Raw(sql, startDate).QueryRows(&list)
- return
- }
- type BaseFromTradeGuangzhouDataResp struct {
- Ret int
- Msg string
- ErrMsg string
- ErrCode string
- Data BaseFromTradeGuangzhouIndexAndDataResp
- }
- // ComTradeIndexDataResp 分页列表响应体
- type BaseFromTradeGuangzhouIndexAndDataResp struct {
- List []*BaseFromTradeGuangzhouData
- Paging *paging.PagingItem `description:"分页数据"`
- }
- // MultiAddBaseFromComTradeData 批量添加数据
- func MultiAddBaseFromTradeGuangzhouData(items []*BaseFromTradeGuangzhouData) (lastId int64, err error) {
- num := len(items)
- if num <= 0 {
- return
- }
- o := orm.NewOrm()
- lastId, err = o.InsertMulti(num, items)
- return
- }
|