Skip to content

Commit

Permalink
feat: 일정 수정 & 삭제 시 해당 팀플레이스의 일정인지 검증 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
SproutMJ committed Jul 28, 2023
1 parent 3470da5 commit ec7ca3d
Showing 1 changed file with 5 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -101,24 +100,19 @@ 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());
}

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

0 comments on commit ec7ca3d

Please sign in to comment.