123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- package data_manage
- import (
- sql2 "database/sql"
- "eta/eta_task/global"
- "eta/eta_task/utils"
- "gorm.io/gorm"
- "time"
- )
- type BaseFromTradeCffexIndex struct {
- BaseFromTradeCffexIndexId int `gorm:"column:base_from_trade_cffex_index_id;primaryKey;autoIncrement"`
- Rank int
- DealShortName string
- DealName string
- DealCode string
- DealValue int
- DealChange int
- BuyShortName string
- BuyName string
- BuyCode string
- BuyValue int
- BuyChange int
- SoldShortName string
- SoldName string
- SoldCode string
- SoldValue int
- SoldChange int
- Frequency string
- ClassifyName string
- ClassifyType string
- CreateTime time.Time
- ModifyTime time.Time
- DataTime string
- }
- func (m *BaseFromTradeCffexIndex) AfterFind(db *gorm.DB) (err error) {
- m.DataTime = utils.GormDateStrToDateStr(m.DataTime)
- return
- }
- func AddBaseFromTradeCffexIndex(item *BaseFromTradeCffexIndex) (lastId int64, err error) {
- err = global.DbMap[utils.DbNameIndex].Create(item).Error
- if err != nil {
- return
- }
- lastId = int64(item.BaseFromTradeCffexIndexId)
- return
- }
- func GetBaseFromTradeCffexIndexAll(dateStr string) (list []*BaseFromTradeCffexIndex, err error) {
- o := global.DbMap[utils.DbNameIndex]
- sql := `SELECT * FROM base_from_trade_cffex_index WHERE data_time=?`
- err = o.Raw(sql, dateStr).Find(&list).Error
- return
- }
- func ModifyBaseFromTradeCffexIndex(columnList [5]string, dataList [5]interface{}, dataId int) (err error) {
- o := global.DbMap[utils.DbNameIndex]
- sql := "UPDATE base_from_trade_cffex_index SET " +
- columnList[0] + "=?," + columnList[1] + "=?," + columnList[2] + "=?," + columnList[3] + "=?," + columnList[4] +
- "=?,modify_time=NOW() WHERE base_from_trade_cffex_index_id=? "
- err = o.Exec(sql, dataList[0], dataList[1], dataList[2], dataList[3], dataList[4], dataId).Error
- return
- }
- type CffexIndexResp struct {
- Ret int
- Msg string
- ErrMsg string
- ErrCode string
- Data []*BaseFromTradeCffexIndex
- }
- func GetBaseFromTradeCffexIndexMaxDate() (maxDate time.Time, err error) {
- o := global.DbMap[utils.DbNameIndex]
- sql := ` SELECT max(a.data_time) AS max_date FROM base_from_trade_cffex_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
- }
|