Skip to content

Commit

Permalink
Merge pull request #105 from Journey-Together/refactor/#101
Browse files Browse the repository at this point in the history
fix : placeReivew jpa수정
  • Loading branch information
sycuuui authored Sep 10, 2024
2 parents 4b2bab1 + 7dd79f3 commit 3b406e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public interface PlaceReviewRepository extends JpaRepository<PlaceReview,Long> {

PlaceReview findPlaceReviewById(Long id);

List<PlaceReview> findTop2ByPlaceAndReportIsNullOrReportFalseOrderByCreatedAtDesc(Place place);
@Query("SELECT pr FROM PlaceReview pr WHERE pr.place = :place AND (pr.report IS NULL OR pr.report = false) ORDER BY pr.createdAt DESC")
List<PlaceReview> findTop2ByPlaceAndReportIsNullOrReportFalseOrderByCreatedAtDesc(@Param("place") Place place, Pageable pageable);

PlaceReview findPlaceReviewByMemberAndPlace(Member member, Place place);
@Query("SELECT COUNT(pr) FROM PlaceReview pr WHERE pr.member = :member")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public PlaceDetailRes getPlaceDetail(Member member, Long placeId){
Boolean isMark = false;

Place place = getPlace(placeId);
System.out.println(place.getId());
Long myPlaceReviewId;

List<PlaceBookmark> placeBookmarkList = placeBookmarkRepository.findAllByPlaceAndMember(place,member);
Expand All @@ -90,8 +91,8 @@ public PlaceDetailRes getPlaceDetail(Member member, Long placeId){

List<Long> disability = disabilityPlaceCategoryRepository.findDisabilityCategoryIds(placeId);
List<SubDisability> subDisability = disabilityPlaceCategoryRepository.findDisabilitySubCategory(placeId).stream().map(SubDisability::of).toList();

List<PlaceReview> placeReviews = placeReviewRepository.findTop2ByPlaceAndReportIsNullOrReportFalseOrderByCreatedAtDesc(place);
Pageable pageable = PageRequest.of(0, 2);
List<PlaceReview> placeReviews = placeReviewRepository.findTop2ByPlaceAndReportIsNullOrReportFalseOrderByCreatedAtDesc(place,pageable);

if(placeReviewRepository.findPlaceReviewByMemberAndPlace(member,place) != null) {
isReview = true;
Expand Down Expand Up @@ -135,7 +136,9 @@ public PlaceDetailGuestRes getGeustPlaceDetail(Long placeId){
List<Long> disability = disabilityPlaceCategoryRepository.findDisabilityCategoryIds(placeId);
List<SubDisability> subDisability = disabilityPlaceCategoryRepository.findDisabilitySubCategory(placeId).stream().map(SubDisability::of).toList();

List<PlaceReview> placeReviews = placeReviewRepository.findTop2ByPlaceAndReportIsNullOrReportFalseOrderByCreatedAtDesc(place);
Pageable pageable = PageRequest.of(0, 2);
List<PlaceReview> placeReviews = placeReviewRepository.findTop2ByPlaceAndReportIsNullOrReportFalseOrderByCreatedAtDesc(place,pageable);

if(placeReviews.size()<0)
return PlaceDetailGuestRes.of(place, placeBookmarkList.size(), disability, subDisability, null);

Expand Down

0 comments on commit 3b406e9

Please sign in to comment.