mirror of
https://github.com/ArvinLovegood/go-stock.git
synced 2025-07-19 00:00:09 +08:00
实时数据只保留最新一条数据
This commit is contained in:
parent
0e743722e1
commit
a99393b4c7
@ -220,7 +220,13 @@ func (receiver StockDataApi) GetStockCodeRealTimeData(StockCode string) (*StockI
|
||||
return &StockInfo{}, nil
|
||||
}
|
||||
stockData, err := ParseFullSingleStockData(GB18030ToUTF8(resp.Body()))
|
||||
//go db.Dao.Model(&StockInfo{}).Create(stockData)
|
||||
var count int64
|
||||
db.Dao.Model(&StockInfo{}).Where("code = ?", StockCode).Count(&count)
|
||||
if count == 0 {
|
||||
go db.Dao.Model(&StockInfo{}).Create(stockData)
|
||||
} else {
|
||||
go db.Dao.Model(&StockInfo{}).Where("code = ?", StockCode).Updates(stockData)
|
||||
}
|
||||
return stockData, err
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user