Skip to content

Commit

Permalink
refactor: modifyDiary 예외처리 플로우 추가 #24
Browse files Browse the repository at this point in the history
  • Loading branch information
masiljangajji committed Dec 8, 2024
1 parent 16086f9 commit 603548b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/main/java/my/music/note/back/service/DiaryService.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,11 @@ public void deleteDiary(Long diaryId, Long userId) {

public void modifyDiary(Long diaryId, Long userId, DiaryModifyRequest diaryModifyRequest) {


if (!diaryRepository.existsByIdAndUserId(userId, diaryId)) {
throw new IllegalArgumentException();
}

Diary diary = diaryRepository.findById(diaryId).get();
Diary diary = diaryRepository.findById(diaryId).orElseThrow(IllegalArgumentException::new);
diary.modifyDiaryContent(diaryModifyRequest);
}

Expand Down

0 comments on commit 603548b

Please sign in to comment.