调整结构
This commit is contained in:
@@ -6,6 +6,7 @@ import cn.stock.market.domain.basic.repository.MoneyStockRepository;
|
|||||||
import cn.stock.market.dto.StockHistoryRequest;
|
import cn.stock.market.dto.StockHistoryRequest;
|
||||||
import cn.stock.market.dto.StockHistoryResponse;
|
import cn.stock.market.dto.StockHistoryResponse;
|
||||||
import cn.stock.market.infrastructure.db.po.QMoneyStockPO;
|
import cn.stock.market.infrastructure.db.po.QMoneyStockPO;
|
||||||
|
import cn.stock.market.utils.ServerResponse;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@@ -159,17 +160,16 @@ public class MoneyApiController {
|
|||||||
})
|
})
|
||||||
@GetMapping("/api/market/money/getStockDetail")
|
@GetMapping("/api/market/money/getStockDetail")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public JSONObject getStockDetail(@RequestParam String stockType, @RequestParam String symbol) {
|
public ServerResponse getStockDetail(@RequestParam String stockType, @RequestParam String symbol) {
|
||||||
String url = String.format("https://priceapi.moneycontrol.com/pricefeed/%s/equitycash/%s",stockType,symbol);
|
String url = String.format("https://priceapi.moneycontrol.com/pricefeed/%s/equitycash/%s",stockType,symbol);
|
||||||
|
|
||||||
// 设置重试次数
|
// 设置重试次数
|
||||||
int maxRetries = 3;
|
int maxRetries = 3;
|
||||||
for (int retry = 1; retry <= maxRetries; retry++) {
|
for (int retry = 1; retry <= maxRetries; retry++) {
|
||||||
try {
|
try {
|
||||||
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.GET, null, String.class);
|
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.GET, null, String.class);
|
||||||
|
|
||||||
if (responseEntity.getStatusCode().value() == 200 && responseEntity.getBody() != null) {
|
if (responseEntity.getStatusCode().value() == 200 && responseEntity.getBody() != null ) {
|
||||||
return JSONObject.parseObject(responseEntity.getBody());
|
return ServerResponse.createBySuccess(JSONObject.parseObject(responseEntity.getBody()).getJSONObject("data"));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user