Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] : 대표 코인 종류 추가 #74

Merged
merged 4 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions backend/src/main/java/org/dgu/backend/constant/Coin.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
public enum Coin {
BITCOIN("KRW-BTC", "비트코인", "Bitcoin"),
ETHEREUM("KRW-ETH", "이더리움", "Ethereum"),
BITCOIN_CASH("KRW-BCH", "비트코인캐시", "Bitcoin Cash"),
SOLANA("KRW-SOL", "솔라나", "Solana"),
AAVE("KRW-AAVE", "에이브", "Aave"),
AVALANCHE("KRW-AVAX", "아발란체", "Avalanche"),
NEO("KRW-NEO", "네오", "NEO"),
TAIKO("KRW-TAIKO", "타이코", "Taiko"),
STACKS("KRW-STX", "스택스", "Stacks"),
RIPPLE("KRW-XRP", "리플", "Ripple"),
DOGECOIN("KRW-DOGE", "도지코인", "Dogecoin"),
WAVE("KRW-WAVES", "웨이브", "Waves");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ResponseEntity<ApiResponse<List<DashBoardDto.UserCoinResponse>>> getUserC
return ApiResponse.onSuccess(SuccessStatus.SUCCESS_GET_USER_COINS, userCoins);
}

// 대표 코인 5개 조회 API
// 대표 코인 12개 조회 API
@GetMapping("/coins/representative")
public ResponseEntity<ApiResponse<List<DashBoardDto.RepresentativeCoinResponse>>> getRepresentativeCoins() {

Expand Down
4 changes: 2 additions & 2 deletions backend/src/main/java/org/dgu/backend/dto/DashBoardDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public static DashBoardDto.RepresentativeCoinResponse of(UpbitDto.Ticker ticker,
.marketName(ticker.getMarket())
.koreanName(koreanName)
.englishName(englishName)
.changePrice(ticker.getPrice())
.changeRate(BigDecimal.valueOf(ticker.getChangeRate()).setScale(5, RoundingMode.HALF_UP))
.changePrice(ticker.getPrice().setScale(0, RoundingMode.UP))
.changeRate(BigDecimal.valueOf(ticker.getChangeRate()).multiply(BigDecimal.valueOf(100)).setScale(3, RoundingMode.HALF_UP))
.isIncrease(ticker.getChange().equals("RISE"))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,21 @@ private DashBoardDto.UserCoinResponse processSingleCoin(UpbitDto.Account account
@Override
public List<DashBoardDto.RepresentativeCoinResponse> getRepresentativeCoins() {
List<DashBoardDto.RepresentativeCoinResponse> representativeCoinResponses = new ArrayList<>();
int requestCount = 0;

for (Coin coin : Coin.values()) {
UpbitDto.Ticker[] ticker = upbitApiClient.getTickerPriceAtUpbit(UPBIT_URL_TICKER + coin.getMarketName());
representativeCoinResponses.add(DashBoardDto.RepresentativeCoinResponse.of(ticker[0], coin.getKoreanName(), coin.getEnglishName()));

requestCount++;
if (requestCount % 10 == 0) {
try {
Thread.sleep(1000); // 1초 대기
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
}
}

return representativeCoinResponses;
Expand Down
Loading