From c64e9fd5bc9610fa48bf75eabd504cf0fd3f57fc Mon Sep 17 00:00:00 2001 From: seungryeol Date: Wed, 31 Jul 2024 03:59:43 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20=EC=9D=BC=EA=B8=B0=20=EB=8C=93=EA=B8=80?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20=EC=A1=B0=EA=B1=B4=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=20/=20farmClubId=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MyVeggieDiaryController.java | 11 +++-------- .../myveggiegarden/repository/DiaryRepository.java | 5 ++--- .../myveggiegarden/service/MyVeggieDiaryService.java | 7 ++----- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/controller/MyVeggieDiaryController.java b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/controller/MyVeggieDiaryController.java index 403a9d69..d5d57d12 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/controller/MyVeggieDiaryController.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/controller/MyVeggieDiaryController.java @@ -107,14 +107,9 @@ public BaseResponseDto cancelLike( return BaseResponseDto.of(SuccessCode.SUCCESS, null); } - @GetMapping(value = "/{diaryId}/{farmClubId}/comment") - public BaseResponseDto selectComment( - @AuthenticationPrincipal CustomUser user, - @PathVariable("diaryId") Long diaryId, - @PathVariable("farmClubId") Long farmClubId - ) { - List diaryCommentList = myVeggieDiaryService.selectComment(user.getUserId(), diaryId, farmClubId); - + @GetMapping(value = "/{diaryId}/comment") + public BaseResponseDto selectComment(@AuthenticationPrincipal CustomUser user, @PathVariable("diaryId") Long diaryId) { + List diaryCommentList = myVeggieDiaryService.selectComment(user.getUserId(), diaryId); return BaseResponseDto.of(SuccessCode.SUCCESS, diaryCommentList); } 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 6b43cfd6..77087673 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 @@ -32,9 +32,8 @@ public interface DiaryRepository extends JpaRepository { "JOIN FETCH dc.diary AS d " + "JOIN FETCH d.myVeggie AS mv " + "JOIN FETCH mv.user " + - "JOIN FETCH d.farmClub " + - "WHERE d.id = :diaryId AND d.farmClub.id = :farmClubId AND d.isOpen = true") - List findDiary(@Param("diaryId") Long diaryId, @Param("farmClubId") Long farmClubId); + "WHERE d.id = :diaryId") + List findDiaryById(@Param("diaryId") Long diaryId); @Query("SELECT d FROM diary AS d " + 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 e34426c9..73de7865 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 @@ -158,11 +158,8 @@ public BaseResponseDto selectDiaryOne( @Transactional - public List selectComment( - Long userId, Long diaryId, Long farmClubId - ) { - - List diaryCommentList = diaryRepository.findDiary(diaryId, farmClubId); + public List selectComment(Long userId, Long diaryId) { + List diaryCommentList = diaryRepository.findDiaryById(diaryId); List diaryCommentContent = DiaryCommentContent.processData(diaryCommentList, userId); return diaryCommentContent; }