调整结构
This commit is contained in:
@@ -60,6 +60,7 @@ public class MoneyApiController {
|
|||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@ApiImplicitParam(name="stockType",value = "BSE或者NSE"),
|
@ApiImplicitParam(name="stockType",value = "BSE或者NSE"),
|
||||||
@ApiImplicitParam(name="symbol",value = "scId值"),
|
@ApiImplicitParam(name="symbol",value = "scId值"),
|
||||||
|
@ApiImplicitParam(name="id",value = "id值"),
|
||||||
})
|
})
|
||||||
@ApiResponses(value = {
|
@ApiResponses(value = {
|
||||||
@ApiResponse(code = 200, message = "" +
|
@ApiResponse(code = 200, message = "" +
|
||||||
@@ -160,16 +161,37 @@ public class MoneyApiController {
|
|||||||
})
|
})
|
||||||
@GetMapping("/api/market/money/getStockDetail")
|
@GetMapping("/api/market/money/getStockDetail")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ServerResponse getStockDetail(@RequestParam String stockType, @RequestParam String symbol) {
|
public ServerResponse getStockDetail(@RequestParam String stockType, @RequestParam String symbol,@RequestParam String id ) {
|
||||||
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);
|
||||||
|
/* MoneyStock moneyStock = moneyStockRepository.findOne(QMoneyStockPO.moneyStockPO.stockType.eq(stockType).and(QMoneyStockPO.moneyStockPO.moneyScId.eq(symbol))).orElse(null);
|
||||||
|
if(moneyStock==null){
|
||||||
|
return ServerResponse.createByErrorMsg("没有找到该股票");
|
||||||
|
}*/
|
||||||
// 设置重试次数
|
// 设置重试次数
|
||||||
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);
|
||||||
|
JSONObject json1 = new JSONObject();
|
||||||
if (responseEntity.getStatusCode().value() == 200 && responseEntity.getBody() != null ) {
|
if (responseEntity.getStatusCode().value() == 200 && responseEntity.getBody() != null ) {
|
||||||
return ServerResponse.createBySuccess(JSONObject.parseObject(responseEntity.getBody()).getJSONObject("data"));
|
JSONObject data = JSONObject.parseObject(responseEntity.getBody()).getJSONObject("data");
|
||||||
|
if(data!=null){
|
||||||
|
json1.put("company",data.getString("company"));
|
||||||
|
json1.put("pricepercentchange",data.getString("pricepercentchange"));
|
||||||
|
json1.put("stockType",stockType);
|
||||||
|
json1.put("pricechange",data.getString("pricechange"));
|
||||||
|
json1.put("pricecurrent",data.getString("pricecurrent"));
|
||||||
|
json1.put("priceprevclose",data.getString("priceprevclose"));
|
||||||
|
json1.put("PREVDATE",data.getString("PREVDATE"));
|
||||||
|
json1.put("VOL",data.getString("VOL"));
|
||||||
|
json1.put("dataSourceType","3");
|
||||||
|
json1.put("symbol",data.getString("symbol"));
|
||||||
|
json1.put("LTH",data.getString("LTH"));
|
||||||
|
json1.put("LTL",data.getString("LTL"));
|
||||||
|
json1.put("OPN",data.getString("OPN"));
|
||||||
|
json1.put("id",id);
|
||||||
|
}
|
||||||
|
return ServerResponse.createBySuccess(json1);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user