loading 오류 수정
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
package com.goldenchart.controller;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.goldenchart.service.MarketQuoteService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 마켓 목록·시세 — 업비트 REST 를 백엔드에서 캐시·스로틀 후 1회 응답.
|
||||
*
|
||||
* GET /api/markets/all
|
||||
* GET /api/markets/tickers?markets=KRW-BTC,KRW-ETH (생략 시 KRW 전 종목)
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/markets")
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class MarketQuoteController {
|
||||
|
||||
private final MarketQuoteService marketQuoteService;
|
||||
|
||||
@GetMapping("/all")
|
||||
public ResponseEntity<List<JsonNode>> getAllMarkets(
|
||||
@RequestParam(defaultValue = "true") boolean isDetails) {
|
||||
try {
|
||||
return ResponseEntity.ok(marketQuoteService.getMarkets(isDetails));
|
||||
} catch (Exception e) {
|
||||
log.warn("[MarketQuote] market/all 실패: {}", e.getMessage());
|
||||
return ResponseEntity.internalServerError().build();
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/tickers")
|
||||
public ResponseEntity<List<JsonNode>> getTickers(
|
||||
@RequestParam(required = false) String markets) {
|
||||
try {
|
||||
List<String> list = markets == null || markets.isBlank()
|
||||
? List.of()
|
||||
: Arrays.stream(markets.split(","))
|
||||
.map(String::trim)
|
||||
.filter(s -> !s.isEmpty())
|
||||
.toList();
|
||||
return ResponseEntity.ok(marketQuoteService.getTickers(list));
|
||||
} catch (Exception e) {
|
||||
log.warn("[MarketQuote] ticker 실패: {}", e.getMessage());
|
||||
return ResponseEntity.internalServerError().build();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user