From 72fef986b84bc28867601d2430af536be4a73ef0 Mon Sep 17 00:00:00 2001 From: seungryeol Date: Wed, 31 Jul 2024 02:56:07 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20=EB=A9=94=EC=9D=B8=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EB=8B=A4=EC=9D=B4=EC=96=B4=EB=A6=AC=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=8B=9C=20=EC=A1=B0=EA=B1=B4=20=EC=B6=94=EA=B0=80?= =?UTF-8?q?=20->=20=EC=98=A4=EB=8A=98=20=EC=93=B4=20=EC=9D=BC=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../myveggiegarden/controller/MyVeggieDiaryController.java | 4 +--- .../domain/myveggiegarden/repository/DiaryRepository.java | 5 +++++ .../domain/myveggiegarden/service/MyVeggieDiaryService.java | 6 ++---- 3 files changed, 8 insertions(+), 7 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..e9efd747 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 @@ -63,9 +63,7 @@ public BaseResponseDto checkTodayDiary( } @GetMapping(value = "/{myVeggieId}/one") - public BaseResponseDto selectDiaryOne( - @PathVariable("myVeggieId") Long myVeggieId - ) { + public BaseResponseDto selectDiaryOne(@PathVariable("myVeggieId") Long myVeggieId) { return myVeggieDiaryService.selectDiaryOne(MyVeggie.builder().id(myVeggieId).build()); } 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..68481a3d 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 @@ -46,4 +46,9 @@ public interface DiaryRepository extends JpaRepository { ) List findDiaryByFarmClub(@Param("farmClubId") Long farmClubId); + @Query("SELECT d FROM diary AS d WHERE d.myVeggie = :myVeggie AND FUNCTION('DATE', d.createdDate) = CURRENT_DATE") + List findDiaryByToday(@Param("myVeggie") MyVeggie myVeggie); + + + } 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..0f1dd7e3 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 @@ -141,10 +141,8 @@ public void updateComment(User user, Long diaryCommentId, String content) { myVeggieRepository.updateDiaryCommentByIdAndUserId(diaryCommentId, user, content); } @Transactional - public BaseResponseDto selectDiaryOne( - MyVeggie myVeggie - ) { - List diaryList = selectDiaryByMyVeggie(myVeggie); + public BaseResponseDto selectDiaryOne(MyVeggie myVeggie) { + List diaryList = diaryRepository.findDiaryByToday(myVeggie); if(diaryList.isEmpty()) { return BaseResponseDto.of(MyVeggieGardenSuccessCode.NOT_FOUND_DIARY, null); }