Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ public record PlaceDetailsGetResponse(
boolean isBookmarked,
long townId,
String townName,
List<PlaceLatestReviewDto> latestReviews
List<PlaceLatestReviewDto> latestReviews,
boolean hasMoreReviews
) {

public static PlaceDetailsGetResponse of(Place place, String mainTag, List<String> optionTags,
List<PlaceImageInfoDto> placeImageInfos, boolean isBookmarked, Town town,
List<PlaceLatestReviewDto> latestReviews) {
List<PlaceLatestReviewDto> latestReviews,
boolean hasMoreReviews) {
return PlaceDetailsGetResponse.builder()
.placeId(place.getId())
.placeName(place.getName())
Expand All @@ -50,6 +52,7 @@ public static PlaceDetailsGetResponse of(Place place, String mainTag, List<Strin
.townId(town.getId())
.townName(town.getName())
.latestReviews(latestReviews)
.hasMoreReviews(hasMoreReviews)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.sopt.solply_server.domain.place.repository.PlaceRepository;
import org.sopt.solply_server.domain.place.repository.PlaceTagRepository;
import org.sopt.solply_server.domain.place.service.facade.PlaceBookmarkFacade;
import org.sopt.solply_server.domain.review.entity.PlaceReview;
import org.sopt.solply_server.domain.review.repository.PlaceReviewRepository;
import org.sopt.solply_server.domain.tag.entity.Tag;
import org.sopt.solply_server.domain.tag.entity.TagType;
Expand Down Expand Up @@ -87,9 +88,13 @@ public PlaceDetailsGetResponse getPlaceDetailsById(final Long userId, final Long

boolean isBookmarked = placeBookmarkFacade.isBookmarked(
userId, placeId, place.getTown().getId());
List<PlaceLatestReviewDto> latestReviews = placeReviewRepository
.findTop3ByPlaceIdOrderByCreatedAtDesc(placeId)
.stream()
List<PlaceReview> reviews = placeReviewRepository
.findTop4ByPlaceIdOrderByCreatedAtDesc(placeId);

boolean hasMoreReviews = reviews.size() > 3;

List<PlaceLatestReviewDto> latestReviews = reviews.stream()
.limit(3)
.map(review -> PlaceLatestReviewDto.from(review, imageUrlProvider))
.toList();
Town town = place.getTown();
Expand All @@ -101,7 +106,8 @@ public PlaceDetailsGetResponse getPlaceDetailsById(final Long userId, final Long
imageInfos,
isBookmarked,
town,
latestReviews
latestReviews,
hasMoreReviews
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ public interface PlaceReviewRepository extends JpaRepository<PlaceReview, Long>
order by pr.createdAt desc
""")
List<PlaceReview> findAllByPlaceIdOrderByCreatedAtDesc(@Param("placeId") Long placeId);
List<PlaceReview> findTop3ByPlaceIdOrderByCreatedAtDesc(Long placeId);
List<PlaceReview> findTop4ByPlaceIdOrderByCreatedAtDesc(Long placeId);
}
Loading