Skip to content

Commit

Permalink
refactor: 도메인 패키지 변경 및 에러코드 병합
Browse files Browse the repository at this point in the history
  • Loading branch information
seunghye218 committed Aug 6, 2024
1 parent 1f3c071 commit 2cc23e0
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 49 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kr.momo.domain.confirmedschedule;
package kr.momo.domain.meeting;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
Expand All @@ -11,7 +11,6 @@
import jakarta.persistence.Table;
import java.time.LocalDateTime;
import kr.momo.domain.BaseEntity;
import kr.momo.domain.meeting.Meeting;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package kr.momo.domain.confirmedschedule;
package kr.momo.domain.meeting;

import java.util.Optional;
import kr.momo.domain.meeting.Meeting;
import org.springframework.data.jpa.repository.JpaRepository;

public interface ConfirmedMeetingRepository extends JpaRepository<ConfirmedMeeting, Long> {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public enum MeetingErrorCode implements ErrorCodeType {
INVALID_TIME_RANGE(HttpStatus.BAD_REQUEST, "끝 시간은 시작 시간 이후가 되어야 합니다."),
MEETING_LOCKED(HttpStatus.BAD_REQUEST, "약속이 잠겨있어 수행할 수 없습니다."),
MEETING_UNLOCKED(HttpStatus.BAD_REQUEST, "약속이 잠겨있지 않아 수행할 수 없습니다."),
ALREADY_EXIST_CONFIRMED_SCHEDULE(HttpStatus.BAD_REQUEST, "이미 확정된 약속입니다."),
INVALID_DATETIME_RANGE(HttpStatus.BAD_REQUEST, "날짜 또는 시간이 잘못되었습니다."),
PAST_NOT_PERMITTED(HttpStatus.BAD_REQUEST, "과거 날짜로는 약속을 생성할 수 없습니다.");

private final HttpStatus httpStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
import kr.momo.domain.attendee.AttendeeRepository;
import kr.momo.domain.availabledate.AvailableDateRepository;
import kr.momo.domain.availabledate.AvailableDates;
import kr.momo.domain.confirmedschedule.ConfirmedMeeting;
import kr.momo.domain.confirmedschedule.ConfirmedMeetingRepository;
import kr.momo.domain.meeting.ConfirmedMeeting;
import kr.momo.domain.meeting.ConfirmedMeetingRepository;
import kr.momo.domain.meeting.Meeting;
import kr.momo.domain.meeting.MeetingRepository;
import kr.momo.exception.MomoException;
import kr.momo.exception.code.AttendeeErrorCode;
import kr.momo.exception.code.ConfirmedScheduleErrorCode;
import kr.momo.exception.code.MeetingErrorCode;
import kr.momo.service.meeting.dto.MeetingConfirmRequest;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -41,7 +40,7 @@ public void create(String uuid, long attendeeId, MeetingConfirmRequest request)
validateHostPermission(attendee);

if (confirmedMeetingRepository.existsByMeeting(meeting)) {
throw new MomoException(ConfirmedScheduleErrorCode.ALREADY_EXIST_CONFIRMED_SCHEDULE);
throw new MomoException(MeetingErrorCode.ALREADY_EXIST_CONFIRMED_SCHEDULE);
}

validateMeetingLocked(meeting);
Expand All @@ -67,7 +66,7 @@ private void validateMeetingLocked(Meeting meeting) {
private void validateTimeRange(Meeting meeting, LocalDateTime startDateTime, LocalDateTime endDateTime) {
if (startDateTime.isAfter(endDateTime)
|| !meeting.isContainedWithinTimeRange(startDateTime.toLocalTime(), endDateTime.toLocalTime())) {
throw new MomoException(ConfirmedScheduleErrorCode.INVALID_DATETIME_RANGE);
throw new MomoException(MeetingErrorCode.INVALID_DATETIME_RANGE);
}
}

Expand All @@ -78,17 +77,17 @@ private void validateDateRange(Meeting meeting, LocalDateTime startDateTime, Loc

if (startDate.equals(endDate)) {
if (availableDates.notExistsByDate(startDate)) {
throw new MomoException(ConfirmedScheduleErrorCode.INVALID_DATETIME_RANGE);
throw new MomoException(MeetingErrorCode.INVALID_DATETIME_RANGE);
}
return;
}

if (meeting.isNotFullTime()) {
throw new MomoException(ConfirmedScheduleErrorCode.INVALID_DATETIME_RANGE);
throw new MomoException(MeetingErrorCode.INVALID_DATETIME_RANGE);
}

if (availableDates.isContainedWithinDateRange(startDate, endDate)) {
throw new MomoException(ConfirmedScheduleErrorCode.INVALID_DATETIME_RANGE);
throw new MomoException(MeetingErrorCode.INVALID_DATETIME_RANGE);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@
import kr.momo.domain.attendee.AttendeeRepository;
import kr.momo.domain.availabledate.AvailableDate;
import kr.momo.domain.availabledate.AvailableDateRepository;
import kr.momo.domain.confirmedschedule.ConfirmedMeeting;
import kr.momo.domain.confirmedschedule.ConfirmedMeetingRepository;
import kr.momo.domain.meeting.ConfirmedMeeting;
import kr.momo.domain.meeting.ConfirmedMeetingRepository;
import kr.momo.domain.meeting.Meeting;
import kr.momo.domain.meeting.MeetingRepository;
import kr.momo.domain.schedule.Schedule;
import kr.momo.domain.schedule.ScheduleRepository;
import kr.momo.domain.timeslot.Timeslot;
import kr.momo.exception.MomoException;
import kr.momo.exception.code.AttendeeErrorCode;
import kr.momo.exception.code.ConfirmedScheduleErrorCode;
import kr.momo.exception.code.MeetingErrorCode;
import kr.momo.exception.code.ScheduleErrorCode;
import kr.momo.fixture.AttendeeFixture;
Expand Down Expand Up @@ -134,7 +133,7 @@ void confirmScheduleThrowsExceptionWhen_AlreadyConfirmed() {

assertThatThrownBy(() -> meetingConfirmService.create(meeting.getUuid(), attendee.getId(), validRequest))
.isInstanceOf(MomoException.class)
.hasMessage(ConfirmedScheduleErrorCode.ALREADY_EXIST_CONFIRMED_SCHEDULE.message());
.hasMessage(MeetingErrorCode.ALREADY_EXIST_CONFIRMED_SCHEDULE.message());
}

@DisplayName("약속에 존재하지 않는 날짜로 일정을 확정 시 예외가 발생한다.")
Expand All @@ -148,7 +147,7 @@ void confirmScheduleThrowsExceptionWhen_InvalidDate() {

assertThatThrownBy(() -> meetingConfirmService.create(meeting.getUuid(), attendee.getId(), request))
.isInstanceOf(MomoException.class)
.hasMessage(ConfirmedScheduleErrorCode.INVALID_DATETIME_RANGE.message());
.hasMessage(MeetingErrorCode.INVALID_DATETIME_RANGE.message());
}

@DisplayName("약속에 포함되지 않은 시간의 일정을 확정 시 예외가 발생한다.")
Expand Down

0 comments on commit 2cc23e0

Please sign in to comment.