From 867379691937b3e8b8e61ec34204edb526230dde Mon Sep 17 00:00:00 2001 From: ArvinLovegood Date: Wed, 19 Mar 2025 14:11:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(stock):=E4=BF=AE=E5=A4=8D=E5=8C=97=E4=BA=A4?= =?UTF-8?q?=E6=89=80=E8=82=A1=E7=A5=A8AI=E5=88=86=E6=9E=90=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E8=82=A1=E4=BB=B7=E8=8E=B7=E5=8F=96=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 SearchStockPriceInfo 函数中增加了对北交所股票代码的处理逻辑 - 更新了测试用例,添加了北交所股票的测试 - 调整了前端组件的样式 --- backend/data/openai_api_test.go | 1 + backend/data/stock_data_api.go | 9 ++++++++- backend/data/stock_data_api_test.go | 4 +++- frontend/src/components/fund.vue | 2 +- frontend/src/components/stock.vue | 2 +- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/backend/data/openai_api_test.go b/backend/data/openai_api_test.go index fe3cfb0..0744467 100644 --- a/backend/data/openai_api_test.go +++ b/backend/data/openai_api_test.go @@ -23,6 +23,7 @@ func TestGetTopNewsList(t *testing.T) { } func TestSearchGuShiTongStockInfo(t *testing.T) { + db.Init("../../data/stock.db") SearchGuShiTongStockInfo("hk01810", 60) SearchGuShiTongStockInfo("sh600745", 60) SearchGuShiTongStockInfo("gb_goog", 60) diff --git a/backend/data/stock_data_api.go b/backend/data/stock_data_api.go index 973f53a..ad0dd61 100644 --- a/backend/data/stock_data_api.go +++ b/backend/data/stock_data_api.go @@ -748,7 +748,14 @@ func GetRealTimeStockPriceInfo(ctx context.Context, stockCode string) (price, pr func SearchStockPriceInfo(stockCode string, crawlTimeOut int64) *[]string { - if strutil.HasPrefixAny(stockCode, []string{"SZ", "SH", "sh", "sz"}) { + if strutil.HasPrefixAny(stockCode, []string{"SZ", "SH", "sh", "sz", "bj"}) { + if strutil.HasPrefixAny(stockCode, []string{"bj", "BJ"}) { + stockCode = strutil.ReplaceWithMap(stockCode, map[string]string{ + "bj": "", + "BJ": "", + }) + ".BJ" + } + return getSHSZStockPriceInfo(stockCode, crawlTimeOut) } if strutil.HasPrefixAny(stockCode, []string{"HK", "hk"}) { diff --git a/backend/data/stock_data_api_test.go b/backend/data/stock_data_api_test.go index a0e2f97..ae2ca55 100644 --- a/backend/data/stock_data_api_test.go +++ b/backend/data/stock_data_api_test.go @@ -46,9 +46,11 @@ func TestSearchStockInfoByCode(t *testing.T) { } func TestSearchStockPriceInfo(t *testing.T) { + db.Init("../../data/stock.db") //SearchStockPriceInfo("hk06030", 30) //SearchStockPriceInfo("sh600171", 30) - SearchStockPriceInfo("gb_aapl", 30) + //SearchStockPriceInfo("gb_aapl", 30) + SearchStockPriceInfo("bj430198", 30) } diff --git a/frontend/src/components/fund.vue b/frontend/src/components/fund.vue index 2dc1170..70888c0 100644 --- a/frontend/src/components/fund.vue +++ b/frontend/src/components/fund.vue @@ -183,7 +183,7 @@ function blinkBorder(findId){ - +