From c25464264e03d6638f39bdae9003d165ad989340 Mon Sep 17 00:00:00 2001 From: hysong4u Date: Fri, 23 Feb 2024 19:25:43 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20tournament=20info=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=EC=8B=9C=201=EB=93=B1=20=EC=83=81=ED=92=88=EC=97=90=20?= =?UTF-8?q?=EB=8C=80=ED=95=9C=20=EC=A0=95=EB=B3=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gift/dto/response/TournamentInfoDto.java | 20 ++++++++++++++----- .../domain/gift/service/GiftService.java | 8 ++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) 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;