Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] 일정 수정 & 삭제 시 해당 팀플레이스의 일정인지 검증 로직 추가 #233

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}