From 5af0af44784e8852bb3c3583a7ca7148102bde19 Mon Sep 17 00:00:00 2001 From: seungryeol Date: Sun, 15 Sep 2024 02:00:39 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[fix]=20=EC=9D=BC=EA=B8=B0=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=8B=9C=20=EC=8B=A0=EA=B3=A0=ED=95=9C=20=EC=9D=BC?= =?UTF-8?q?=EA=B8=B0=20=EC=95=88=EB=B3=B4=EC=9E=84=20=EC=A1=B0=EA=B1=B4=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/myveggiegarden/repository/DiaryRepository.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/repository/DiaryRepository.java b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/repository/DiaryRepository.java index a6c7006..5a5e33f 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/repository/DiaryRepository.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/repository/DiaryRepository.java @@ -42,8 +42,10 @@ public interface DiaryRepository extends JpaRepository { "FROM diary AS d " + "JOIN FETCH d.myVeggie AS mv " + "LEFT JOIN diary_like AS dl ON dl.diary.id = d.id AND dl.user.id = :userId " + - "WHERE d.farmClub.id = :farmClubId AND d.isOpen = true " - ) + "LEFT JOIN diary_report AS dr ON dr.diary.id = d.id AND dr.user.id = :userId " + + "WHERE d.farmClub.id = :farmClubId AND d.isOpen = true "+ + "AND dr.id IS NULL" + ) List findDiaryByFarmClub(@Param("farmClubId") Long farmClubId, @Param("userId") Long userId); @Query("SELECT new com.modernfarmer.farmusspring.domain.myveggiegarden.dto.SortedMyLikeDiary(d, " + From df43b513c26f23f29f365e5396ddd1aa7598e872 Mon Sep 17 00:00:00 2001 From: seungryeol Date: Sun, 15 Sep 2024 02:51:20 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[fix]=20=EC=9D=BC=EA=B8=B0=20=EB=8C=93?= =?UTF-8?q?=EA=B8=80=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EC=8B=A0=EA=B3=A0?= =?UTF-8?q?=ED=95=9C=20=EC=9D=BC=EA=B8=B0=20=EB=8C=93=EA=B8=80=20=EC=95=88?= =?UTF-8?q?=EB=B3=B4=EC=9E=84=20=EC=A1=B0=EA=B1=B4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/myveggiegarden/repository/DiaryRepository.java | 7 +++++-- .../myveggiegarden/service/MyVeggieDiaryService.java | 5 ++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/repository/DiaryRepository.java b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/repository/DiaryRepository.java index 5a5e33f..a89205f 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/repository/DiaryRepository.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/repository/DiaryRepository.java @@ -34,8 +34,11 @@ public interface DiaryRepository extends JpaRepository { "JOIN FETCH dc.diary AS d " + "JOIN FETCH d.myVeggie AS mv " + "JOIN FETCH mv.user " + - "WHERE d.id = :diaryId") - List findDiaryById(@Param("diaryId") Long diaryId); + "LEFT JOIN diary_comment_report AS dcr ON dcr.diaryComment.id = dc.id AND dcr.user.id = :userId " + + "WHERE d.id = :diaryId " + + "AND dcr.id IS NULL" + ) + List findDiaryByIdWithUserId(@Param("diaryId") Long diaryId, @Param("userId") Long userId); @Query("SELECT new com.modernfarmer.farmusspring.domain.myveggiegarden.dto.SortedMyLikeDiary(d, " + "CASE WHEN d.myVeggie.user.id = :userId THEN true ELSE false END, " + "CASE WHEN dl.user.id = :userId THEN true ELSE false END) " + diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/service/MyVeggieDiaryService.java b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/service/MyVeggieDiaryService.java index 3bcdcb0..fdbc209 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/service/MyVeggieDiaryService.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/service/MyVeggieDiaryService.java @@ -116,8 +116,7 @@ public void verifyMyVeggie(Optional myVeggie){ @Transactional public List findDiaryAccordingToFarmClub(Long farmClubId, Long userId) { List diaryList = diaryRepository.findDiaryByFarmClub(farmClubId, userId); - List proccessData = proccessFarmClubData(diaryList); - return proccessData; + return proccessFarmClubData(diaryList); } private List proccessFarmClubData(List diaryAllList){ return diaryAllList.stream().map(allDiary -> { @@ -195,7 +194,7 @@ public BaseResponseDto selectDiaryOne(MyVeggie myVeggie) } @Transactional public DiaryInteractionsDto selectComment(Long userId, Long diaryId) { - List diaryCommentList = diaryRepository.findDiaryById(diaryId); + List diaryCommentList = diaryRepository.findDiaryByIdWithUserId(diaryId, userId); List diaryCommentContent = DiaryCommentContent.processData(diaryCommentList, userId); int likeCount = diaryLikeRepository.findDiaryLikeCountById(diaryId); int commentCount = diaryCommentRepository.findDiaryCommentCountById(diaryId);