继续优化代码

This commit is contained in:
Achilles
2024-01-06 13:00:50 +08:00
parent f0bd124afb
commit bf81ef6a44

View File

@@ -242,7 +242,7 @@ public class MoneyApiController {
String stockUrl = company_a.attr("href"); String stockUrl = company_a.attr("href");
String stockName = company_a.text(); String stockName = company_a.text();
dto.setStockName(stockName); dto.setStockName(stockName);
dto.setStockUrl(stockUrl); //dto.setStockUrl(stockUrl);
} }
String highPrice = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(2)").first()); String highPrice = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(2)").first());
@@ -263,6 +263,7 @@ public class MoneyApiController {
String changePercent = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(7)").first()); String changePercent = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(7)").first());
dto.setChangePercent(changePercent); dto.setChangePercent(changePercent);
dto.setStockType("bse");
list.add(dto); list.add(dto);
log.info("---------------------------------------------" + i); log.info("---------------------------------------------" + i);
} }
@@ -286,7 +287,7 @@ public class MoneyApiController {
String stockUrl = company_a.attr("href"); String stockUrl = company_a.attr("href");
String stockName = company_a.text(); String stockName = company_a.text();
dto.setStockName(stockName); dto.setStockName(stockName);
dto.setStockUrl(stockUrl); // dto.setStockUrl(stockUrl);
} }
String highPrice = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(2)").first()); String highPrice = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(2)").first());
@@ -330,7 +331,7 @@ public class MoneyApiController {
if (company_a != null) { if (company_a != null) {
String stockUrl = company_a.attr("href"); String stockUrl = company_a.attr("href");
String stockName = company_a.text(); String stockName = company_a.text();
dto.setStockUrl(stockUrl); //dto.setStockUrl(stockUrl);
dto.setStockName(stockName); dto.setStockName(stockName);
} }
@@ -374,7 +375,7 @@ public class MoneyApiController {
if (company_a != null) { if (company_a != null) {
String stockUrl = company_a.attr("href"); String stockUrl = company_a.attr("href");
String stockName = company_a.text(); String stockName = company_a.text();
dto.setStockUrl(stockUrl); // dto.setStockUrl(stockUrl);
dto.setStockName(stockName); dto.setStockName(stockName);
} }
@@ -418,7 +419,7 @@ public class MoneyApiController {
String stockUrl = company_a.attr("href"); String stockUrl = company_a.attr("href");
String stockName = company_a.text(); String stockName = company_a.text();
dto.setStockName(stockName); dto.setStockName(stockName);
dto.setStockUrl(stockUrl); //dto.setStockUrl(stockUrl);
} }
@@ -439,6 +440,7 @@ public class MoneyApiController {
String changePercent = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(7)").first()); String changePercent = getTextOrEmpty(doc.select("#mc_content > section > section > div.clearfix.stat_container > div.columnst.FR.wbg.brdwht > div > div > div.bsr_table.hist_tbl_hm > table > tbody > tr:nth-child(" + i + ") > td:nth-child(7)").first());
dto.setChangePercent(changePercent); dto.setChangePercent(changePercent);
dto.setStockType("bse");
list.add(dto); list.add(dto);
log.info("---------------------------------------------" + i); log.info("---------------------------------------------" + i);
} }
@@ -530,7 +532,7 @@ public class MoneyApiController {
@ApiResponse(code = 200, message = "" + @ApiResponse(code = 200, message = "" +
"股票推荐相关: top active", response = JSONObject.class), "股票推荐相关: top active", response = JSONObject.class),
}) })
@GetMapping("/api/market/money/getTopActive") @GetMapping("/api/market/money/getTopActives")
@ResponseBody @ResponseBody
public List<MoneyStockSuggestDTO> getTopActive(@RequestParam String stockType) { public List<MoneyStockSuggestDTO> getTopActive(@RequestParam String stockType) {
List<MoneyStockSuggestDTO> moneyStockSuggestDTOS = null; List<MoneyStockSuggestDTO> moneyStockSuggestDTOS = null;