diff --git a/backend/src/main/java/com/staccato/travel/service/TravelService.java b/backend/src/main/java/com/staccato/travel/service/TravelService.java index 155e8f870..0bd620304 100644 --- a/backend/src/main/java/com/staccato/travel/service/TravelService.java +++ b/backend/src/main/java/com/staccato/travel/service/TravelService.java @@ -21,7 +21,6 @@ import com.staccato.visit.repository.VisitImageRepository; import com.staccato.visit.repository.VisitRepository; import com.staccato.visit.service.dto.response.VisitResponse; -import com.staccato.visit.service.dto.response.VisitResponses; import lombok.RequiredArgsConstructor; @@ -89,7 +88,7 @@ private TravelResponses getTravelResponses(List travelMembers) { public TravelDetailResponse readTravelById(long travelId) { Travel travel = getTravelById(travelId); - VisitResponses visitResponses = getVisitResponses(visitRepository.findAllByTravelIdAndIsDeletedIsFalse(travelId)); + List visitResponses = getVisitResponses(visitRepository.findAllByTravelIdAndIsDeletedIsFalse(travelId)); return new TravelDetailResponse(travel, visitResponses); } @@ -98,10 +97,10 @@ private Travel getTravelById(long travelId) { .orElseThrow(() -> new StaccatoException("요청하신 여행을 찾을 수 없어요.")); } - private VisitResponses getVisitResponses(List visits) { - return new VisitResponses(visits.stream() + private List getVisitResponses(List visits) { + return visits.stream() .map(visit -> new VisitResponse(visit, getFirstVisitImageUrl(visit))) - .toList()); + .toList(); } private String getFirstVisitImageUrl(Visit visit) { diff --git a/backend/src/main/java/com/staccato/travel/service/dto/response/TravelDetailResponse.java b/backend/src/main/java/com/staccato/travel/service/dto/response/TravelDetailResponse.java index 9198e0c5e..3de3c83f4 100644 --- a/backend/src/main/java/com/staccato/travel/service/dto/response/TravelDetailResponse.java +++ b/backend/src/main/java/com/staccato/travel/service/dto/response/TravelDetailResponse.java @@ -1,11 +1,12 @@ package com.staccato.travel.service.dto.response; import java.time.LocalDate; +import java.util.List; import com.fasterxml.jackson.annotation.JsonInclude; -import com.staccato.member.service.dto.response.MemberResponses; +import com.staccato.member.service.dto.response.MemberResponse; import com.staccato.travel.domain.Travel; -import com.staccato.visit.service.dto.response.VisitResponses; +import com.staccato.visit.service.dto.response.VisitResponse; public record TravelDetailResponse( Long travelId, @@ -14,10 +15,10 @@ public record TravelDetailResponse( @JsonInclude(JsonInclude.Include.NON_NULL) String description, LocalDate startAt, LocalDate endAt, - MemberResponses mates, - VisitResponses visits + List mates, + List visits ) { - public TravelDetailResponse(Travel travel, VisitResponses visitResponses) { + public TravelDetailResponse(Travel travel, List visitResponses) { this( travel.getId(), travel.getThumbnailUrl(), @@ -25,8 +26,12 @@ public TravelDetailResponse(Travel travel, VisitResponses visitResponses) { travel.getDescription(), travel.getStartAt(), travel.getEndAt(), - MemberResponses.from(travel.getMates()), + toMemberResponses(travel), visitResponses ); } + + private static List toMemberResponses(Travel travel) { + return travel.getMates().stream().map(MemberResponse::new).toList(); + } } diff --git a/backend/src/test/java/com/staccato/travel/service/TravelServiceTest.java b/backend/src/test/java/com/staccato/travel/service/TravelServiceTest.java index 6e2491786..ffa618445 100644 --- a/backend/src/test/java/com/staccato/travel/service/TravelServiceTest.java +++ b/backend/src/test/java/com/staccato/travel/service/TravelServiceTest.java @@ -104,9 +104,9 @@ void readTravelById() { // then assertAll( () -> assertThat(travelDetailResponse.travelId()).isEqualTo(targetId), - () -> assertThat(travelDetailResponse.mates().members()).hasSize(1), - () -> assertThat(travelDetailResponse.visits().visits()).hasSize(1), - () -> assertThat(travelDetailResponse.visits().visits().get(0).visitId()).isEqualTo(visit.getId()) + () -> assertThat(travelDetailResponse.mates()).hasSize(1), + () -> assertThat(travelDetailResponse.visits()).hasSize(1), + () -> assertThat(travelDetailResponse.visits().get(0).visitId()).isEqualTo(visit.getId()) ); }