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); }