From d6a3361cbcb2ecf24d72f0b7df0ff5e909a731c4 Mon Sep 17 00:00:00 2001 From: masiljangajji Date: Mon, 9 Dec 2024 00:01:49 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20Diary=20queryById=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 --- .../my/music/note/back/data/repository/DiaryRepository.java | 2 ++ src/main/java/my/music/note/back/service/DiaryService.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/my/music/note/back/data/repository/DiaryRepository.java b/src/main/java/my/music/note/back/data/repository/DiaryRepository.java index cca81d2..dcab850 100644 --- a/src/main/java/my/music/note/back/data/repository/DiaryRepository.java +++ b/src/main/java/my/music/note/back/data/repository/DiaryRepository.java @@ -15,4 +15,6 @@ public interface DiaryRepository extends JpaRepository { Optional findByUserIdAndIdAndIsDeletedFalse(Long userId,Long diaryId); + Diary queryById(Long diaryId); + } 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 906c003..c7cbcdd 100644 --- a/src/main/java/my/music/note/back/service/DiaryService.java +++ b/src/main/java/my/music/note/back/service/DiaryService.java @@ -45,7 +45,7 @@ public void modifyDiary(Long diaryId, Long userId, DiaryModifyRequest diaryModif throw new IllegalArgumentException(); } - Diary diary = diaryRepository.findById(diaryId).orElseThrow(IllegalArgumentException::new); + Diary diary = diaryRepository.queryById(diaryId); diary.modifyDiaryContent(diaryModifyRequest); }