Skip to content

Commit

Permalink
Merge branch 'refs/heads/dev' into feature_41/미션목록-api-수정
Browse files Browse the repository at this point in the history
  • Loading branch information
MinchoGreenT committed Jul 31, 2024
2 parents d1a5ab5 + 052da71 commit 904e9a1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 27 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 Expand Up @@ -107,14 +105,9 @@ public BaseResponseDto<?> cancelLike(
return BaseResponseDto.of(SuccessCode.SUCCESS, null);
}

@GetMapping(value = "/{diaryId}/{farmClubId}/comment")
public BaseResponseDto<?> selectComment(
@AuthenticationPrincipal CustomUser user,
@PathVariable("diaryId") Long diaryId,
@PathVariable("farmClubId") Long farmClubId
) {
List<DiaryCommentContent> diaryCommentList = myVeggieDiaryService.selectComment(user.getUserId(), diaryId, farmClubId);

@GetMapping(value = "/{diaryId}/comment")
public BaseResponseDto<?> selectComment(@AuthenticationPrincipal CustomUser user, @PathVariable("diaryId") Long diaryId) {
List<DiaryCommentContent> diaryCommentList = myVeggieDiaryService.selectComment(user.getUserId(), diaryId);
return BaseResponseDto.of(SuccessCode.SUCCESS, diaryCommentList);
}

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 @@ -32,9 +32,8 @@ public interface DiaryRepository extends JpaRepository<Diary, Long> {
"JOIN FETCH dc.diary AS d " +
"JOIN FETCH d.myVeggie AS mv " +
"JOIN FETCH mv.user " +
"JOIN FETCH d.farmClub " +
"WHERE d.id = :diaryId AND d.farmClub.id = :farmClubId AND d.isOpen = true")
List<DiaryComment> findDiary(@Param("diaryId") Long diaryId, @Param("farmClubId") Long farmClubId);
"WHERE d.id = :diaryId")
List<DiaryComment> findDiaryById(@Param("diaryId") Long diaryId);


@Query("SELECT d FROM diary AS d " +
Expand All @@ -46,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 All @@ -158,11 +156,8 @@ public BaseResponseDto<SelectDiaryOneResponse> selectDiaryOne(


@Transactional
public List<DiaryCommentContent> selectComment(
Long userId, Long diaryId, Long farmClubId
) {

List<DiaryComment> diaryCommentList = diaryRepository.findDiary(diaryId, farmClubId);
public List<DiaryCommentContent> selectComment(Long userId, Long diaryId) {
List<DiaryComment> diaryCommentList = diaryRepository.findDiaryById(diaryId);
List<DiaryCommentContent> diaryCommentContent = DiaryCommentContent.processData(diaryCommentList, userId);
return diaryCommentContent;
}
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 904e9a1

Please sign in to comment.