Skip to content

Commit

Permalink
Bug: 충돌 해결 (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyukjinKimm authored Jul 16, 2024
1 parent 39553bb commit 419ad78
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class DiaryService {
private final DiaryRetriever diaryRetriever;
private final ReplyService replyService;
private final DiaryCreator diaryCreator;
private final DiaryRemover diaryRemover;

public DiaryListGetResponse getDiaryList(int year, int month) {
Map<LocalDate, List<Diary>> diariesByDate = getDiariesMap(year, month);
Map<LocalDate, Reply> repliesByDate = getRepliesMap(year, month);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ public List<Reply> getRepliesByUserAndDateBetween(User user, LocalDate start, Lo

return replyRepository.findByUserIdAndDiaryCreatedDateBetween(user.getId(), start, end);
}

public boolean isReplyExist(Long userId, int year, int month, int date) {
LocalDate localDate = LocalDate.of(year, month, date);
return replyRepository.existsByUserIdAndDiaryCreatedDate(userId, localDate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,12 @@ public List<Reply> getRepliesByUserAndDateBetween(User user, LocalDate start, Lo

return replyRetriever.getRepliesByUserAndDateBetween(user, start, end);
}

public boolean isReplyExist(Long userId, int year, int month, int date) {
return replyRetriever.isReplyExist(userId, year, month, date);
}

public void removeReply(Long userId, int year, int month, int date) {
replyRemover.removeReplyUserIdAndDate(userId, year, month, date);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,12 @@ ResponseEntity<ApiResponse<DiaryCreatedTimeGetResponse>> getDiaryCreatedTime(
@RequestParam @Parameter(name = "달", description = "조회할 달", required = true) final int month,
@RequestParam @Parameter(name = "일", description = "조회할 일", required = true) final int day
);

@Operation(summary = "일기 삭제 ", description = "년/월/일을 이용하여 일기와 답변까지 삭제합니다. 만약 답변이 요청 중인 상태라면, 답변을 요청하지 않습니다.")
@DeleteMapping("/diary")
ResponseEntity<ApiResponse<?>> deleteDiary(
@RequestParam @Parameter(name = "연도", description = "삭제할 연도", required = true) final int year,
@RequestParam @Parameter(name = "달", description = "삭제할 달", required = true) final int month,
@RequestParam @Parameter(name = "일", description = "삭제할 일", required = true) final int day
);
}

0 comments on commit 419ad78

Please sign in to comment.