diff --git a/src/main/java/org/sopt/sweet/domain/gift/dto/response/TournamentInfoDto.java b/src/main/java/org/sopt/sweet/domain/gift/dto/response/TournamentInfoDto.java index 42cc190..3146f2c 100644 --- a/src/main/java/org/sopt/sweet/domain/gift/dto/response/TournamentInfoDto.java +++ b/src/main/java/org/sopt/sweet/domain/gift/dto/response/TournamentInfoDto.java @@ -7,18 +7,28 @@ @Builder public record TournamentInfoDto( + + String firstplaceGiftName, + String firstplaceGiftImageUrl, + int firstplaceGiftCost, LocalDateTime remainingTime, int totalParticipantsCount, int participantsCount ) { - public static TournamentInfoDto of(LocalDateTime remainingTime, - int TotalParticipantsCount, - int ParticipantsCount) { + public static TournamentInfoDto of( String firstplaceGiftName, + String firstplaceGiftImageUrl, + int firstplaceGiftCost, + LocalDateTime remainingTime, + int totalParticipantsCount, + int participantsCount) { return TournamentInfoDto.builder() + .firstplaceGiftName(firstplaceGiftName) + .firstplaceGiftImageUrl(firstplaceGiftImageUrl) + .firstplaceGiftCost(firstplaceGiftCost) .remainingTime(remainingTime) - .totalParticipantsCount(TotalParticipantsCount) - .participantsCount(ParticipantsCount) + .totalParticipantsCount(totalParticipantsCount) + .participantsCount(participantsCount) .build(); } diff --git a/src/main/java/org/sopt/sweet/domain/gift/service/GiftService.java b/src/main/java/org/sopt/sweet/domain/gift/service/GiftService.java index 5a84c75..126df50 100644 --- a/src/main/java/org/sopt/sweet/domain/gift/service/GiftService.java +++ b/src/main/java/org/sopt/sweet/domain/gift/service/GiftService.java @@ -201,6 +201,9 @@ private Gift updateScore(Long giftId, int score) { public TournamentInfoDto getTournamentInfo(Long memberId, Long roomId) { Room room = findRoomByIdOrThrow(roomId); + RoomMember roomMember = roomMemberRepository.findByRoomIdAndMemberId(roomId, memberId); + Gift firstPlaceGift = giftRepository.findById(roomMember.getFirstplaceGiftId()) + .orElseThrow(() -> new EntityNotFoundException(GIFT_NOT_FOUND)); LocalDateTime tournamentStartDate = room.getTournamentStartDate(); TournamentDuration tournamentDuration = room.getTournamentDuration(); @@ -212,10 +215,11 @@ public TournamentInfoDto getTournamentInfo(Long memberId, Long roomId) { LocalDateTime tournamentEndTime = getTournamentEndDate(tournamentStartDate, tournamentDuration); LocalDateTime remainingTime =getTournamentRemainingTime(tournamentEndTime); - return new TournamentInfoDto(remainingTime, totalParticipantsCount, participatingMembersCount); + return new TournamentInfoDto( + firstPlaceGift.getName(), firstPlaceGift.getImageUrl(), firstPlaceGift.getCost(), + remainingTime, totalParticipantsCount, participatingMembersCount); } - private LocalDateTime getTournamentEndDate(LocalDateTime tournamentStartDate, TournamentDuration tournamentDuration) { LocalDateTime tournamentEndTime = tournamentStartDate.plusHours(tournamentDuration.getHours()); return tournamentEndTime;