We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0e74372 commit a99393bCopy full SHA for a99393b
backend/data/stock_data_api.go
@@ -220,7 +220,13 @@ func (receiver StockDataApi) GetStockCodeRealTimeData(StockCode string) (*StockI
220
return &StockInfo{}, nil
221
}
222
stockData, err := ParseFullSingleStockData(GB18030ToUTF8(resp.Body()))
223
- //go db.Dao.Model(&StockInfo{}).Create(stockData)
+ var count int64
224
+ db.Dao.Model(&StockInfo{}).Where("code = ?", StockCode).Count(&count)
225
+ if count == 0 {
226
+ go db.Dao.Model(&StockInfo{}).Create(stockData)
227
+ } else {
228
+ go db.Dao.Model(&StockInfo{}).Where("code = ?", StockCode).Updates(stockData)
229
+ }
230
return stockData, err
231
232
0 commit comments