Skip to content

Commit

Permalink
FU-191 feat: 운영시간 단위 변경시 기본 스케줄 초기화
Browse files Browse the repository at this point in the history
  • Loading branch information
yuseok0215 committed Dec 19, 2024
1 parent edf51b9 commit cb0a911
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
@RequiredArgsConstructor
public enum ScheduleErrorCode implements ErrorCode {

START_TIME_AFTER_END_TIME(400, "시작시간이 종료시간보다 더 늦습니다.");
START_TIME_AFTER_END_TIME(400, "시작시간과 종료시간이 올바르지 않습니다."),
CANNOT_CHANGE_SAME_SCHEDULE_UNIT(400, "같은 스케줄 단위로는 변경할 수 없습니다.");


private final int httpStatus;
private final String message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ public void updateScheduleTime(LocalTime startTime, LocalTime endTime, Operation
this.operationStatus = operationStatus;
}

public void initializeSchedule() {
this.startTime = LocalTime.of(9,0,0);
this.endTime = LocalTime.of(18,0,0);
this.operationStatus = OperationStatus.ACTIVE;
}

@Builder
public BaseSchedule(Member photographer, DayOfWeek dayOfWeek, LocalTime startTime, LocalTime endTime,
OperationStatus operationStatus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ public ScheduleUnitDto getScheduleUnit(Long photographerId) {
@Transactional
public void updateScheduleUnit(Long photographerId, ScheduleUnitDto scheduleUnitDto) {
Member photographer = getMember(photographerId);

if (photographer.getScheduleUnit() == scheduleUnitDto.getScheduleUnit()) {
throw new RestApiException(ScheduleErrorCode.CANNOT_CHANGE_SAME_SCHEDULE_UNIT);
}

List<BaseSchedule> baseScheduleList = baseScheduleRepository.findByPhotographerId(photographer.getId());
for (BaseSchedule baseSchedule : baseScheduleList) {
baseSchedule.initializeSchedule();
}

photographer.updateScheduleUnit(scheduleUnitDto.getScheduleUnit());
}

Expand Down

0 comments on commit cb0a911

Please sign in to comment.