From 7fd916a219f21c2aa4f7259302eb82de1f1579b2 Mon Sep 17 00:00:00 2001 From: dengli Date: Sat, 16 Dec 2023 19:13:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=87=BA=E5=8F=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../stock/market/web/StockApiController.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/cn/stock/market/web/StockApiController.java b/src/main/java/cn/stock/market/web/StockApiController.java index 59a2e6e..b6c8c5e 100644 --- a/src/main/java/cn/stock/market/web/StockApiController.java +++ b/src/main/java/cn/stock/market/web/StockApiController.java @@ -127,12 +127,7 @@ public class StockApiController { public ServerResponse getINDStockInfo(@RequestParam("stockCode") String stockCode) { ParamUtils.verify("股票代码", stockCode, ParamUtils.STRING_NOT_EMPTY_VERIFY_AND_CONVERT_VALUE); - IndiaStockVO market = null; - try { - market = InvestingApis.of().market(StockCode.of(stockCode)); - } catch (Exception e) { - return ServerResponse.createByErrorMsg("tips.msg.221"); - } + IndiaStockVO market = InvestingApis.of().market(StockCode.of(stockCode)); return ServerResponse.createBySuccess(market.toStockVo()); } @@ -193,9 +188,15 @@ public class StockApiController { @ApiImplicitParam(name = "code",value = "股票对应代码(symbol)",dataType ="String",required = true), }) public ServerResponse getSingleStock(@RequestParam("code") String code) { - return RequestCacheUtils.cache("getSingleStock.do", code, (string) -> { - return this.stockService.getSingleStock(code); - }); + ServerResponse cache = null; + try { + cache = RequestCacheUtils.cache("getSingleStock.do", code, (string) -> { + return this.stockService.getSingleStock(code); + }); + } catch (Exception e) { + return ServerResponse.createByErrorMsg("tips.msg.221"); + } + return cache; } @RequestMapping({"getMinK.do"})