From c4a2a0c09f9c4a2af997e9123966293985037fd1 Mon Sep 17 00:00:00 2001 From: seungryeol Date: Wed, 31 Jul 2024 03:20:31 +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=A3=A8=ED=8B=B4=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C?= =?UTF-8?q?=20=EC=A1=B0=EA=B1=B4=20=EC=B6=94=EA=B0=80=20->=20=EC=98=A4?= =?UTF-8?q?=EB=8A=98=20=ED=95=B4=EC=95=BC=ED=95=A0=20=EB=A3=A8=ED=8B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../myveggiegarden/controller/MyVeggieRoutineController.java | 4 +--- .../domain/myveggiegarden/repository/RoutineRepository.java | 3 +++ .../domain/myveggiegarden/service/MyVeggieRoutineService.java | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/controller/MyVeggieRoutineController.java b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/controller/MyVeggieRoutineController.java index d019f8ae..2b553155 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/controller/MyVeggieRoutineController.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/controller/MyVeggieRoutineController.java @@ -62,9 +62,7 @@ public BaseResponseDto checkVeggieRoutine(@Validated @RequestBody RoutineChec } @GetMapping(value = "/{myVeggieId}") - public BaseResponseDto selectMyVeggieRoutineById( - @PathVariable("myVeggieId") Long myVeggieId - ) { + public BaseResponseDto selectRoutineToday(@PathVariable("myVeggieId") Long myVeggieId) { MyVeggie myVeggie = MyVeggie.builder().id(myVeggieId).build(); List result = myVeggieRoutineService.selectMyVeggieRoutineById(myVeggie); return BaseResponseDto.of(SuccessCode.SUCCESS, result); diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/repository/RoutineRepository.java b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/repository/RoutineRepository.java index 7a875755..28fc8837 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/repository/RoutineRepository.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/repository/RoutineRepository.java @@ -39,4 +39,7 @@ public interface RoutineRepository extends JpaRepository { "FUNCTION('YEAR', r.date) = FUNCTION('YEAR', :month) AND FUNCTION('MONTH', r.date) = FUNCTION('MONTH', :month)") List findRoutineAndRoutineAndMyVeggieByMonthWithUser(@Param("month") Date month, @Param("user") User user ); + + @Query("SELECT r FROM routine AS r WHERE r.myVeggie = :myVeggie AND r.date = CURRENT_DATE") + List findRoutineByIdAndToday(@Param("myVeggie") MyVeggie myVeggie); } \ No newline at end of file diff --git a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/service/MyVeggieRoutineService.java b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/service/MyVeggieRoutineService.java index 16eb71d0..ee1fcdcd 100644 --- a/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/service/MyVeggieRoutineService.java +++ b/src/main/java/com/modernfarmer/farmusspring/domain/myveggiegarden/service/MyVeggieRoutineService.java @@ -51,7 +51,7 @@ public void eraseRoutine(RoutineDelete routineDelete) { @Transactional public List selectMyVeggieRoutineById(MyVeggie myVeggie) { - List routineList = myVeggieRepository.findMyVeggieRoutineById(myVeggie); + List routineList = routineRepository.findRoutineByIdAndToday(myVeggie); return MyVeggieRoutine.processData(routineList); }