Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

리뷰 이미지 코드 오타 수정 #195

Merged
merged 1 commit into from
Nov 11, 2023
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 @@ -71,13 +71,11 @@ public void addReview(User user, Long chatId, ReviewRequest.AddDTO request) {
public ReviewResponse.FindAllByPlannerDTO findReviewsByPlanner(int page, Long plannerId) {
Pageable pageable = PageRequest.of(page, PAGE_SIZE);
Page<Review> pageContent = reviewJPARepository.findAllByMatchPlannerId(plannerId, pageable);
System.out.println("1번!");

List<Review> reviews = pageContent.getContent();
System.out.println("2번!");
List<Long> reviewIds = reviews.stream().map(Review::getId).toList();
System.out.println("3번!");
List<ReviewImageItem> reviewImageItems = reviewImageItemJPARepository.findAllByReviewIds(reviewIds);
System.out.println("4번!");

return reviewDTOConverter.getFindAllByPlannerDTO(reviews, reviewImageItems);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
public interface ReviewImageItemJPARepository extends JpaRepository<ReviewImageItem, Long> {

@Modifying
@Query("delete from ReviewImageItem i where i.review.id = :reviewId")
@Query("delete from ReviewImageItem r where r.review.id = :reviewId")
void deleteAllByReviewId(@Param("reviewId") Long reviewId);

@Query("select i from ReviewImageItem i join fetch i.review r where r.id in :reviewIds")
@Query("select ri from ReviewImageItem ri join fetch ri.review r where r.id in :reviewIds")
List<ReviewImageItem> findAllByReviewIds(@Param("reviewIds") List<Long> reviewIds);

@Query("select i.image from ReviewImageItem i where i.review.id = :reviewId")
@Query("select r.image from ReviewImageItem r where r.review.id = :reviewId")
List<String> findByReviewId(@Param("reviewId") Long reviewId);
}
Loading
Loading