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"})