refactor(data):优化数据处理和格式化

- 修改 OpenAI 消息内容格式,增加日期信息
- 重置股票指数和基本信息的 ID 为 0,以确保正确插入数据库
This commit is contained in:
spark 2025-02-19 20:37:56 +08:00
parent 5ccbbb6bb5
commit 0ff14fc01c
2 changed files with 3 additions and 1 deletions

View File

@ -179,7 +179,7 @@ func (o OpenAi) NewChatStream(stock, stockCode, userQuestion string) <-chan map[
}
msg = append(msg, map[string]interface{}{
"role": "assistant",
"content": stock + "当前价格:" + price,
"content": stock + time.Now().Format(time.DateOnly) + "价格:" + price,
})
}()

View File

@ -226,6 +226,7 @@ func (receiver StockDataApi) GetIndexBasic() {
if err != nil {
continue
}
index.ID = 0
db.Dao.Model(&IndexBasic{}).FirstOrCreate(index, &IndexBasic{TsCode: index.TsCode}).Where("ts_code = ?", index.TsCode).Updates(index)
}
@ -274,6 +275,7 @@ func (receiver StockDataApi) GetStockBaseInfo() {
if err != nil {
continue
}
stock.ID = 0
db.Dao.Model(&StockBasic{}).FirstOrCreate(stock, &StockBasic{TsCode: stock.TsCode}).Where("ts_code = ?", stock.TsCode).Updates(stock)
}