Skip to content

Commit

Permalink
[#177] refactor(PerformanceUpdateService): 기존 회차 수 + 회차 추가 수가 3 초과시 에…
Browse files Browse the repository at this point in the history
…러처리 추가
  • Loading branch information
hoonyworld committed Aug 21, 2024
1 parent 5934345 commit 65cc779
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.beat.domain.staff.dao.StaffRepository;
import com.beat.domain.staff.domain.Staff;
import com.beat.domain.staff.exception.StaffErrorCode;
import com.beat.global.common.exception.BadRequestException;
import com.beat.global.common.exception.NotFoundException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -128,6 +129,13 @@ private void updatePerformanceDetails(Performance performance, PerformanceUpdate

private List<ScheduleAddResponse> addSchedules(List<ScheduleAddRequest> requests, Performance performance) {
log.debug("Adding schedules for performanceId: {}", performance.getId());

long existingSchedulesCount = scheduleRepository.countByPerformanceId(performance.getId());

if (requests != null && (existingSchedulesCount + requests.size()) > 3) {
throw new BadRequestException(PerformanceErrorCode.MAX_SCHEDULE_LIMIT_EXCEEDED);
}

if (requests == null || requests.isEmpty()) {
log.debug("No schedules to add for performanceId: {}", performance.getId());
return List.of();
Expand Down

0 comments on commit 65cc779

Please sign in to comment.