123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package trade_analysis
- import (
- "eta_gn/eta_api/global"
- "time"
- )
- // BaseFromTradeClassify 交易所分类表
- type BaseFromTradeClassify struct {
- Id uint64 `orm:"column(id);pk" gorm:"primaryKey" `
- ClassifyName string //分类名称
- ClassifyType string //分类名称下的类型
- Exchange string //交易所
- LatestDate time.Time //数据最近的日期
- CreateTime time.Time //插入时间
- ModifyTime time.Time //修改时间
- }
- // GetAllBaseFromTradeClassify 获取所有的交易所分类列表
- func GetAllBaseFromTradeClassify() (list []*BaseFromTradeClassify, err error) {
- sql := `SELECT * FROM base_from_trade_classify `
- err = global.DmSQL["data"].Raw(sql).Find(&list).Error
- return
- }
- func GetTradeTopLastDataTime(exchange string, classifyName, classifyType string) (item *BaseFromTradeClassify, err error) {
- sql := `SELECT * FROM base_from_trade_classify WHERE exchange = ? AND classify_name=? `
- pars := make([]interface{}, 0)
- pars = append(pars, exchange)
- if exchange == "zhengzhou" {
- pars = append(pars, classifyType)
- } else {
- pars = append(pars, classifyName)
- sql += ` AND classify_type=? `
- pars = append(pars, classifyType)
- }
- sql += ` ORDER BY latest_date desc`
- err = global.DmSQL["data"].Raw(sql, pars...).First(&item).Error
- return
- }
- // GetClassifyTypeByClassifyName 根据分类名称获取分类类型
- func GetClassifyTypeByClassifyName(exchange, classifyName string) (item *TradeClassifyName, err error) {
- sql := `SELECT classify_name, classify_type FROM base_from_trade_classify WHERE exchange = ? AND classify_name=? `
- err = global.DmSQL["data"].Raw(sql, exchange, classifyName).First(&item).Error
- return
- }
|