Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/Mojacknong/Farmus-Spring int…
Browse files Browse the repository at this point in the history
…o fix_50/일기-댓글
  • Loading branch information
Ryeolee committed Jul 31, 2024
2 parents c64e9fd + accc3fa commit 3b5eb08
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ public BaseResponseDto<CheckTodayDiaryResponse> checkTodayDiary(
}

@GetMapping(value = "/{myVeggieId}/one")
public BaseResponseDto<SelectDiaryOneResponse> selectDiaryOne(
@PathVariable("myVeggieId") Long myVeggieId
) {
public BaseResponseDto<SelectDiaryOneResponse> selectDiaryOne(@PathVariable("myVeggieId") Long myVeggieId) {
return myVeggieDiaryService.selectDiaryOne(MyVeggie.builder().id(myVeggieId).build());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<MyVeggieRoutine> result = myVeggieRoutineService.selectMyVeggieRoutineById(myVeggie);
return BaseResponseDto.of(SuccessCode.SUCCESS, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,9 @@ public interface DiaryRepository extends JpaRepository<Diary, Long> {
)
List<Diary> findDiaryByFarmClub(@Param("farmClubId") Long farmClubId);

@Query("SELECT d FROM diary AS d WHERE d.myVeggie = :myVeggie AND FUNCTION('DATE', d.createdDate) = CURRENT_DATE")
List<Diary> findDiaryByToday(@Param("myVeggie") MyVeggie myVeggie);



}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ public interface RoutineRepository extends JpaRepository<Routine, Long> {
"FUNCTION('YEAR', r.date) = FUNCTION('YEAR', :month) AND FUNCTION('MONTH', r.date) = FUNCTION('MONTH', :month)")
List<Routine> 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<Routine> findRoutineByIdAndToday(@Param("myVeggie") MyVeggie myVeggie);
}
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,8 @@ public void updateComment(User user, Long diaryCommentId, String content) {
myVeggieRepository.updateDiaryCommentByIdAndUserId(diaryCommentId, user, content);
}
@Transactional
public BaseResponseDto<SelectDiaryOneResponse> selectDiaryOne(
MyVeggie myVeggie
) {
List<Diary> diaryList = selectDiaryByMyVeggie(myVeggie);
public BaseResponseDto<SelectDiaryOneResponse> selectDiaryOne(MyVeggie myVeggie) {
List<Diary> diaryList = diaryRepository.findDiaryByToday(myVeggie);
if(diaryList.isEmpty()) {
return BaseResponseDto.of(MyVeggieGardenSuccessCode.NOT_FOUND_DIARY, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void eraseRoutine(RoutineDelete routineDelete) {

@Transactional
public List<MyVeggieRoutine> selectMyVeggieRoutineById(MyVeggie myVeggie) {
List<Routine> routineList = myVeggieRepository.findMyVeggieRoutineById(myVeggie);
List<Routine> routineList = routineRepository.findRoutineByIdAndToday(myVeggie);
return MyVeggieRoutine.processData(routineList);
}

Expand Down

0 comments on commit 3b5eb08

Please sign in to comment.