From 603548bb0109000c059ea164f48c50e3f34309f3 Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Sun, 8 Dec 2024 23:11:33 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20modifyDiary=20=EC=98=88=EC=99=B8?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=ED=94=8C=EB=A1=9C=EC=9A=B0=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20#24?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/my/music/note/back/service/DiaryService.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/my/music/note/back/service/DiaryService.java b/src/main/java/my/music/note/back/service/DiaryService.java index 7b84994..906c003 100644 --- a/src/main/java/my/music/note/back/service/DiaryService.java +++ b/src/main/java/my/music/note/back/service/DiaryService.java @@ -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); }