From ec7ca3d06346ba0157db26b9595d592052dd1415 Mon Sep 17 00:00:00 2001 From: SproutMj Date: Fri, 28 Jul 2023 12:06:58 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=9D=BC=EC=A0=95=20=EC=88=98=EC=A0=95?= =?UTF-8?q?=20&=20=EC=82=AD=EC=A0=9C=20=EC=8B=9C=20=ED=95=B4=EB=8B=B9=20?= =?UTF-8?q?=ED=8C=80=ED=94=8C=EB=A0=88=EC=9D=B4=EC=8A=A4=EC=9D=98=20?= =?UTF-8?q?=EC=9D=BC=EC=A0=95=EC=9D=B8=EC=A7=80=20=EA=B2=80=EC=A6=9D=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/TeamCalendarScheduleService.java | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/backend/src/main/java/team/teamby/teambyteam/schedule/application/TeamCalendarScheduleService.java b/backend/src/main/java/team/teamby/teambyteam/schedule/application/TeamCalendarScheduleService.java index d0aa61811..ce6c877e0 100644 --- a/backend/src/main/java/team/teamby/teambyteam/schedule/application/TeamCalendarScheduleService.java +++ b/backend/src/main/java/team/teamby/teambyteam/schedule/application/TeamCalendarScheduleService.java @@ -3,7 +3,6 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import team.teamby.teambyteam.member.domain.MemberRepository; import team.teamby.teambyteam.schedule.application.dto.ScheduleRegisterRequest; import team.teamby.teambyteam.schedule.application.dto.ScheduleResponse; import team.teamby.teambyteam.schedule.application.dto.ScheduleUpdateRequest; @@ -101,6 +100,7 @@ public void update(final ScheduleUpdateRequest scheduleUpdateRequest, final Long final Schedule schedule = scheduleRepository.findById(scheduleId) .orElseThrow(ScheduleException.ScheduleNotFoundException::new); + validateScheduleOwnerTeam(teamPlaceId, schedule); schedule.change(scheduleUpdateRequest.title(), scheduleUpdateRequest.startDateTime(), scheduleUpdateRequest.endDateTime()); @@ -108,17 +108,11 @@ public void update(final ScheduleUpdateRequest scheduleUpdateRequest, final Long public void delete(final Long teamPlaceId, final Long scheduleId) { checkTeamPlaceExist(teamPlaceId); - checkScheduleExist(scheduleId); - scheduleRepository.deleteById(scheduleId); - } - private void checkScheduleExist(final Long scheduleId) { - if (notExistSchedule(scheduleId)) { - throw new ScheduleException.ScheduleNotFoundException(); - } - } + final Schedule schedule = scheduleRepository.findById(scheduleId) + .orElseThrow(ScheduleException.ScheduleNotFoundException::new); + validateScheduleOwnerTeam(teamPlaceId, schedule); - private boolean notExistSchedule(final Long scheduleId) { - return !scheduleRepository.existsById(scheduleId); + scheduleRepository.deleteById(scheduleId); } }