From 44173f307bfb11f999f625d84d6a763ede963c3f Mon Sep 17 00:00:00 2001 From: yechan-kim <60172300+yechan-kim@users.noreply.github.com> Date: Sun, 24 Nov 2024 02:23:36 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=88=9C=EC=9C=84=EA=B0=80=20=EB=B6=80?= =?UTF-8?q?=EB=B6=84=EC=97=90=20=EC=83=81=EA=B4=80=EC=97=86=EC=9D=B4=20?= =?UTF-8?q?=EB=8F=99=EC=9D=BC=ED=95=98=EA=B2=8C=20=EB=B0=98=ED=99=98?= =?UTF-8?q?=EB=90=98=EB=8A=94=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/character/usecase/RankService.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/dpbr/dpbrbe/domain/character/usecase/RankService.java b/src/main/java/com/dpbr/dpbrbe/domain/character/usecase/RankService.java index d99b44c..9493bbf 100644 --- a/src/main/java/com/dpbr/dpbrbe/domain/character/usecase/RankService.java +++ b/src/main/java/com/dpbr/dpbrbe/domain/character/usecase/RankService.java @@ -1,9 +1,11 @@ package com.dpbr.dpbrbe.domain.character.usecase; import java.util.List; +import java.util.concurrent.atomic.AtomicLong; import org.springframework.stereotype.Service; +import com.dpbr.dpbrbe.domain.character.domain.Character; import com.dpbr.dpbrbe.domain.character.domain.repository.CharacterRepository; import com.dpbr.dpbrbe.domain.character.presentation.dto.response.CharacterInfoResponse; import com.dpbr.dpbrbe.domain.character.presentation.dto.response.CharacterRankingResponse; @@ -17,25 +19,31 @@ public class RankService { private final CharacterRepository characterRepository; public List level() { + AtomicLong rank = new AtomicLong(1); + return characterRepository.findAllByOrderByLevelDesc().stream() .map(character -> CharacterRankingResponse.of( - (long)(characterRepository.findAllByOrderByLevelDesc().indexOf(character) + 1), + rank.getAndIncrement(), CharacterInfoResponse.from(character))) .toList(); } public List combatPower() { + AtomicLong rank = new AtomicLong(1); + return characterRepository.findAllByOrderByCombatPowerDesc().stream() .map(character -> CharacterRankingResponse.of( - (long)(characterRepository.findAllByOrderByLevelDesc().indexOf(character) + 1), + rank.getAndIncrement(), CharacterInfoResponse.from(character))) .toList(); } public List unionLevel() { + AtomicLong rank = new AtomicLong(1); + return characterRepository.findAllByOrderByUnionLevelDesc().stream() .map(character -> CharacterRankingResponse.of( - (long)(characterRepository.findAllByOrderByLevelDesc().indexOf(character) + 1), + rank.getAndIncrement(), CharacterInfoResponse.from(character))) .toList(); }