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

refactor: 하루 지난 회의에 대한 예외 삭제 #79

Merged
merged 1 commit into from
Aug 26, 2024
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
27 changes: 11 additions & 16 deletions src/main/java/org/dnd/timeet/meeting/domain/Meeting.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,13 @@ public void endMeeting() {

if (this.status == MeetingStatus.COMPLETED) {
throw new BadRequestError(ErrorCode.WRONG_REQUEST_TRANSMISSION,
Collections.singletonMap("MeetingId", "Meeting already completed"));
Collections.singletonMap("MeetingId", "Meeting already completed"));
}

this.status = MeetingStatus.COMPLETED;

Duration duration = Duration.between(startTime, endTime);

if (duration.getSeconds() > 24 * 3600) { // 하루를 초과하는 경우
throw new BadRequestError(ErrorCode.WRONG_REQUEST_TRANSMISSION,
Collections.singletonMap("Meeting", "Meeting duration exceeds one day"));
}

this.totalActualDuration = duration;
}

Expand All @@ -125,7 +120,7 @@ public void cancelMeeting() {
public void updateStartTime(LocalDateTime startTime) {
if (this.status != MeetingStatus.SCHEDULED) {
throw new BadRequestError(BadRequestError.ErrorCode.WRONG_REQUEST_TRANSMISSION,
Collections.singletonMap("Meeting", "MeetingStatus is not SCHEDULED"));
Collections.singletonMap("Meeting", "MeetingStatus is not SCHEDULED"));
}
this.startTime = startTime;
}
Expand All @@ -142,9 +137,9 @@ public void assignNewHostRandomly() {
}

List<Member> participantsList = this.participants.stream()
.map(Participant::getMember)
.filter(member -> !member.equals(this.hostMember)) // 현재 방장 제외
.toList();
.map(Participant::getMember)
.filter(member -> !member.equals(this.hostMember)) // 현재 방장 제외
.toList();

// 회의에 방장만 존재할 경우
if (participantsList.isEmpty()) {
Expand Down Expand Up @@ -175,10 +170,10 @@ public Duration calculateCurrentDuration() {
return this.totalActualDuration;
case CANCELED:
throw new BadRequestError(ErrorCode.WRONG_REQUEST_TRANSMISSION,
Collections.singletonMap("Meeting", "Meeting is CANCELED"));
Collections.singletonMap("Meeting", "Meeting is CANCELED"));
default:
throw new BadRequestError(ErrorCode.WRONG_REQUEST_TRANSMISSION,
Collections.singletonMap("Meeting", "MeetingStatus is not valid"));
Collections.singletonMap("Meeting", "MeetingStatus is not valid"));
}
}

Expand All @@ -193,23 +188,23 @@ public Duration calculateRemainingTime() {
return Duration.ZERO;
case CANCELED:
throw new BadRequestError(ErrorCode.WRONG_REQUEST_TRANSMISSION,
Collections.singletonMap("Meeting", "Meeting is CANCELED"));
Collections.singletonMap("Meeting", "Meeting is CANCELED"));
default:
throw new BadRequestError(ErrorCode.WRONG_REQUEST_TRANSMISSION,
Collections.singletonMap("Meeting", "MeetingStatus is not valid"));
Collections.singletonMap("Meeting", "MeetingStatus is not valid"));
}
}

public boolean isMemberParticipating(Member member) {
return this.participants.stream()
.anyMatch(participant -> participant.getMember().equals(member));
.anyMatch(participant -> participant.getMember().equals(member));
}

public Participant addParticipant(Member member) {
// 이미 참가중인 회원이라면 예외 발생
if (this.isMemberParticipating(member)) {
throw new BadRequestError(BadRequestError.ErrorCode.DUPLICATE_RESOURCE,
Collections.singletonMap("Member", "Member already participating in the meeting"));
Collections.singletonMap("Member", "Member already participating in the meeting"));
}

// 회의에 아무도 없다면 방장으로 지정
Expand Down
Loading