调整结构

This commit is contained in:
Achilles
2024-01-08 15:15:30 +08:00
parent d5a3fddbd4
commit f1c3f718f0

View File

@@ -6,6 +6,7 @@ import cn.stock.market.domain.basic.repository.MoneyStockRepository;
import cn.stock.market.dto.StockHistoryRequest;
import cn.stock.market.dto.StockHistoryResponse;
import cn.stock.market.infrastructure.db.po.QMoneyStockPO;
import cn.stock.market.utils.ServerResponse;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import io.swagger.annotations.Api;
@@ -159,17 +160,16 @@ public class MoneyApiController {
})
@GetMapping("/api/market/money/getStockDetail")
@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);
// 设置重试次数
int maxRetries = 3;
for (int retry = 1; retry <= maxRetries; retry++) {
try {
ResponseEntity<String> responseEntity = restTemplate.exchange(url, HttpMethod.GET, null, String.class);
if (responseEntity.getStatusCode().value() == 200 && responseEntity.getBody() != null) {
return JSONObject.parseObject(responseEntity.getBody());
if (responseEntity.getStatusCode().value() == 200 && responseEntity.getBody() != null ) {
return ServerResponse.createBySuccess(JSONObject.parseObject(responseEntity.getBody()).getJSONObject("data"));
}
} catch (Exception e) {