From 899ac0d67f984ef674ce1f24c71752cf03cf7c82 Mon Sep 17 00:00:00 2001 From: dengli Date: Sat, 2 Dec 2023 11:34:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=82=A1=E7=A5=A8=E5=88=97=E8=A1=A8=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/basic/service/StockService.java | 20 +++++++++++++++++++ .../stock/market/web/StockApiController.java | 8 ++++++++ 2 files changed, 28 insertions(+) diff --git a/src/main/java/cn/stock/market/domain/basic/service/StockService.java b/src/main/java/cn/stock/market/domain/basic/service/StockService.java index 54b5b68..fc734fe 100644 --- a/src/main/java/cn/stock/market/domain/basic/service/StockService.java +++ b/src/main/java/cn/stock/market/domain/basic/service/StockService.java @@ -17,6 +17,7 @@ import cn.stock.market.utils.*; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.google.common.base.Stopwatch; import okhttp3.OkHttpClient; import okhttp3.Protocol; import okhttp3.Request; @@ -724,6 +725,25 @@ public class StockService { return null; } + //印度股票列表 英财 + public ServerResponse getINDStockList(Integer pageSize, Integer pageNum) { + String sina_result = ""; + try { + String tmpl = "https://api.investing.com/api/financialdata/assets/equitiesByCountry/default?fields-list=id,name,symbol,high,low,last,lastPairDecimal,change,changePercent,volume,time,isOpen,url,flag,countryNameTranslated,exchangeId,performanceDay,performanceWeek,performanceMonth,performanceYtd,performanceYear,performance3Year,technicalHour,technicalDay,technicalWeek,technicalMonth,avgVolume,fundamentalMarketCap,fundamentalRevenue,fundamentalRatio,fundamentalBeta,pairType&country-id=14&page={}&page-size={}&include-major-indices=false&include-additional-indices=false&include-primary-sectors=false&include-other-indices=false&limit=0"; + String url = StrFormatter.format(tmpl, pageNum, pageSize); + Stopwatch stopwatch = Stopwatch.createStarted(); + log.info("url: {}", url); + Builder builder = new Request.Builder().url(url).method("GET", null); + String body = httpClient().newCall(builder.build()).execute().body().string(); + sina_result = JSON.parseObject(body).toString(); + return ServerResponse.createBySuccess(sina_result); + + } catch (Exception e) { + log.error("获取出错,错误信息 = {}", e); + } + return null; + } + //印度股票时线-K线 public ServerResponse getTimeK(String stockCode) { String sina_result = ""; diff --git a/src/main/java/cn/stock/market/web/StockApiController.java b/src/main/java/cn/stock/market/web/StockApiController.java index 7dbb2fd..8298b11 100644 --- a/src/main/java/cn/stock/market/web/StockApiController.java +++ b/src/main/java/cn/stock/market/web/StockApiController.java @@ -122,6 +122,14 @@ public class StockApiController { return this.stockService.getYCStockInfo(stockCode); } + //印度股票列表 英情 + @RequestMapping({"getINDStockList.do"}) + @ApiOperation(value = "印度股票列表", httpMethod = "GET") + @ResponseBody + public ServerResponse getINDStockList(@RequestParam("pageSize") Integer pageSize, @RequestParam("pageNum") Integer pageNum) { + return this.stockService.getINDStockList(pageSize, pageNum); + } + //印度股票时线-K线 @RequestMapping({"getINDTimeK.do"}) @ApiOperation(value = "印度股票K线", httpMethod = "GET")