123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- package data_manage
- import (
- sql2 "database/sql"
- "eta/eta_task/global"
- "eta/eta_task/utils"
- "gorm.io/gorm"
- "time"
- )
- type BaseFromTradeDalianIndex struct {
- BaseFromTradeDalianIndexId int `gorm:"column:base_from_trade_dalian_index_id;primaryKey;autoIncrement"`
- Rank string `description:"排名"`
- DealShortName string `description:"成交量公司简称"`
- DealName string `description:"成交量指标名称"`
- DealCode string `description:"成交量指标编码"`
- DealValue string `description:"成交量"`
- DealChange string `description:"成交变化量"`
- BuyShortName string `description:"成交量公司简称"`
- BuyName string `description:"持买单量指标名称"`
- BuyCode string `description:"持买单量指标编码"`
- BuyValue string `description:"持买单量"`
- BuyChange string `description:"持买单量变化量"`
- SoldShortName string `description:"成交量公司简称"`
- SoldName string `description:"持买单量指标名称"`
- SoldCode string `description:"持买单量指标编码"`
- SoldValue string `description:"持买单量"`
- SoldChange string `description:"持买单量变化量"`
- Frequency string `description:"频度"`
- ClassifyName string `description:"分类名称"`
- ClassifyType string `description:"分类名称下的类型"`
- CreateTime string `description:"插入时间"`
- ModifyTime string `description:"修改时间"`
- DataTime string `description:"数据日期"`
- }
- func (m *BaseFromTradeDalianIndex) AfterFind(db *gorm.DB) (err error) {
- m.DataTime = utils.GormDateStrToDateStr(m.DataTime)
- return
- }
- func AddBaseFromTradeDalianIndex(item *BaseFromTradeDalianIndex) (lastId int64, err error) {
- err = global.DbMap[utils.DbNameIndex].Create(item).Error
- if err != nil {
- return
- }
- lastId = int64(item.BaseFromTradeDalianIndexId)
- return
- }
- type BaseFromTradeDalianData struct {
- BaseFromTradeDalianDataId int `gorm:"column:base_from_trade_dalian_data_id;primaryKey;autoIncrement"`
- BaseFromTradeDalianIndexId int
- IndexCode string
- DataTime time.Time
- Value string
- AddCutValue string
- CreateTime time.Time
- ModifyTime time.Time
- DataTimestamp string
- }
- func GetBaseFromTradeDalianDataList(dateTime string) (items []*BaseFromTradeDalianIndex, err error) {
- o := global.DbMap[utils.DbNameIndex]
- sql := `SELECT * FROM base_from_trade_dalian_index WHERE data_time>=?`
- err = o.Raw(sql, dateTime).Find(&items).Error
- return
- }
- type DalianIndexResp struct {
- Ret int
- Msg string
- ErrMsg string
- ErrCode string
- Data []*BaseFromTradeDalianIndex
- }
- func GetBaseFromTradeDalianIndexMaxDate() (maxDate time.Time, err error) {
- o := global.DbMap[utils.DbNameIndex]
- sql := ` SELECT max(a.data_time) AS max_date FROM base_from_trade_dalian_index as a `
- var timeNull sql2.NullTime
- err = o.Raw(sql).Scan(&timeNull).Error
- if err != nil {
- return
- }
- if timeNull.Valid {
- maxDate = timeNull.Time
- }
- return
- }
|