From 69e77da28904c3dbd3a980e593a111b91503f6cf Mon Sep 17 00:00:00 2001 From: Sangkwon Lee Date: Mon, 23 Sep 2024 20:56:44 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=9D=BC=EC=A0=95=20=EC=83=81=EC=84=B8?= =?UTF-8?q?=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95=20(=EB=B9=88=20?= =?UTF-8?q?=EB=A6=AC=EC=8A=A4=ED=8A=B8=EB=8F=84=20=EA=B0=80=EB=8A=A5?= =?UTF-8?q?=ED=95=98=EA=B2=8C=EB=81=94,=20=EB=8D=94=EB=B6=88=EC=96=B4?= =?UTF-8?q?=EC=84=9C=20=EC=82=AD=EC=A0=9C=20=EC=A0=9C=EB=8C=80=EB=A1=9C=20?= =?UTF-8?q?=EB=8F=99=EC=9E=91=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ArticleScheduleWriterService.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/java/site/travellaboratory/be/article/application/service/_schedule/ArticleScheduleWriterService.java b/src/main/java/site/travellaboratory/be/article/application/service/_schedule/ArticleScheduleWriterService.java index e7a8f3a..c97eb09 100644 --- a/src/main/java/site/travellaboratory/be/article/application/service/_schedule/ArticleScheduleWriterService.java +++ b/src/main/java/site/travellaboratory/be/article/application/service/_schedule/ArticleScheduleWriterService.java @@ -63,21 +63,23 @@ public ArticleScheduleUpdateResponse updateSchedules(Long userId, Long articleId for (ArticleSchedule existingSchedule : existingSchedules) { // 기존 일정에는 있는데 요청에 없다면? 삭제 처리 if (!requestMap.containsKey(existingSchedule.getId())) { - existingSchedule.delete(user); + articleScheduleJpaRepository.save(ArticleScheduleEntity.from(existingSchedule.delete(user))); } } - // (3) 작성, 수정 처리 - for (ArticleScheduleRequest request : requests) { - ArticleSchedule articleSchedule; - if (request.scheduleId() == null) { - // id x -> 새로운 일정 생성 - articleSchedule = ArticleSchedule.create(user, article, request); - } else { - // id o -> 기존 일정 수정 - articleSchedule = getExistingScheduleById(existingSchedules, request.scheduleId()).update(user, request); + if (!requests.isEmpty()) { + // (3) 작성, 수정 처리 + for (ArticleScheduleRequest request : requests) { + ArticleSchedule articleSchedule; + if (request.scheduleId() == null) { + // id x -> 새로운 일정 생성 + articleSchedule = ArticleSchedule.create(user, article, request); + } else { + // id o -> 기존 일정 수정 + articleSchedule = getExistingScheduleById(existingSchedules, request.scheduleId()).update(user, request); + } + articleScheduleJpaRepository.save(ArticleScheduleEntity.from(articleSchedule)); } - articleScheduleJpaRepository.save(ArticleScheduleEntity.from(articleSchedule)); } return ArticleScheduleUpdateResponse.from(articleEntity.getId());