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); } }