From ec8860734d7dcd33805a3b75129cf36c43c6f7d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=95=88=ED=9B=88=EA=B8=B0?= Date: Mon, 9 Mar 2026 11:38:04 +0900 Subject: [PATCH] =?UTF-8?q?:recycle:Refactor:=20MatchDetailResponse=20?= =?UTF-8?q?=EC=9D=91=EB=8B=B5=20=EA=B5=AC=EC=A1=B0=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../match/dto/response/MatchDetailResponse.java | 16 ++++++++++++---- .../domain/match/service/MatchServiceImpl.java | 10 +++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/be/sportizebe/domain/match/dto/response/MatchDetailResponse.java b/src/main/java/com/be/sportizebe/domain/match/dto/response/MatchDetailResponse.java index cb50bf9..7edb507 100644 --- a/src/main/java/com/be/sportizebe/domain/match/dto/response/MatchDetailResponse.java +++ b/src/main/java/com/be/sportizebe/domain/match/dto/response/MatchDetailResponse.java @@ -1,5 +1,6 @@ package com.be.sportizebe.domain.match.dto.response; +import com.be.sportizebe.domain.facility.entity.SportsFacility; import com.be.sportizebe.domain.match.entity.MatchParticipantStatus; import com.be.sportizebe.domain.match.entity.MatchRoom; import com.be.sportizebe.common.enums.SportType; @@ -21,6 +22,12 @@ public record MatchDetailResponse( @Schema(description = "체육시설 ID", example = "987") Long facilityId, + @Schema(description = "체육시설 이름", example = "마포 풋살파크") + String facilityName, + + @Schema(description = "체육시설 주소", example = "서울 마포구 월드컵로 123") + String facilityAddress, + @Schema(description = "최대 참여 가능 인원", example = "12") Integer maxMembers, @@ -39,21 +46,22 @@ public record MatchDetailResponse( ) { public static MatchDetailResponse of( MatchRoom matchRoom, - User user + User user, + SportsFacility facility ) { - // JOINED 상태인 참가자만 추출 List participantIds = matchRoom.getParticipants().stream() .filter(p -> p.getStatus() == MatchParticipantStatus.JOINED) .map(p -> p.getUser().getId()) .toList(); - // 요청 유저가 참가 중인지 여부 판단 boolean joined = participantIds.contains(user.getId()); return new MatchDetailResponse( matchRoom.getId(), matchRoom.getSportsName(), matchRoom.getFacilityId(), + facility.getFacilityName(), + facility.getAddress(), matchRoom.getMaxMembers(), participantIds.size(), participantIds, @@ -61,4 +69,4 @@ public static MatchDetailResponse of( matchRoom.getScheduledAt() ); } -} \ No newline at end of file +} diff --git a/src/main/java/com/be/sportizebe/domain/match/service/MatchServiceImpl.java b/src/main/java/com/be/sportizebe/domain/match/service/MatchServiceImpl.java index 721c39e..835df28 100644 --- a/src/main/java/com/be/sportizebe/domain/match/service/MatchServiceImpl.java +++ b/src/main/java/com/be/sportizebe/domain/match/service/MatchServiceImpl.java @@ -10,6 +10,9 @@ import com.be.sportizebe.domain.match.exception.MatchErrorCode; import com.be.sportizebe.domain.match.repository.MatchParticipantRepository; import com.be.sportizebe.domain.match.repository.MatchRoomRepository; +import com.be.sportizebe.domain.facility.entity.SportsFacility; +import com.be.sportizebe.domain.facility.exception.FacilityErrorCode; +import com.be.sportizebe.domain.facility.repository.SportsFacilityRepository; import com.be.sportizebe.domain.user.entity.User; import com.be.sportizebe.domain.user.exception.UserErrorCode; import com.be.sportizebe.domain.user.repository.UserRepository; @@ -29,6 +32,7 @@ public class MatchServiceImpl implements MatchService { private final MatchRoomRepository matchRoomRepository; private final MatchParticipantRepository matchParticipantRepository; private final UserRepository userRepository; + private final SportsFacilityRepository sportsFacilityRepository; @Override // 실제로는 관리자용 메서드인데 더미 넣으려고 만듦 @@ -117,13 +121,13 @@ public void leaveMatch(Long matchId, Long userId) { @Override @Transactional(readOnly = true) public MatchDetailResponse getMatchDetail(Long matchId, Long userId) { - // 1) 매칭방 존재 확인 MatchRoom matchRoom = matchRoomRepository.findById(matchId) .orElseThrow(() -> new CustomException(MatchErrorCode.MATCH_NOT_FOUND)); User user = userRepository.findById(userId) .orElseThrow(() -> new CustomException(UserErrorCode.USER_NOT_FOUND)); - // 2) 응답 DTO 생성 (matchRoom + user 기준 정보 포함) - return MatchDetailResponse.of(matchRoom, user); + SportsFacility facility = sportsFacilityRepository.findById(matchRoom.getFacilityId()) + .orElseThrow(() -> new CustomException(FacilityErrorCode.FACILITY_NOT_FOUND)); + return MatchDetailResponse.of(matchRoom, user, facility); } @Override