Skip to content

Commit

Permalink
Merge pull request #48 from Mojacknong/fix_46/메인-일기-조회
Browse files Browse the repository at this point in the history
[fix] 메인페이지 다이어리 조회 시 조건 추가 -> 오늘 쓴 일기
  • Loading branch information
MinchoGreenT authored Jul 31, 2024
2 parents f2869e7 + 72fef98 commit 14d694f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 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 @@ -46,4 +46,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 @@ -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

0 comments on commit 14d694f

Please sign in to comment.