Skip to content

Commit

Permalink
Merge pull request #79 from dnd-side-project/refactor/meeting
Browse files Browse the repository at this point in the history
refactor: 하루 지난 회의에 대한 예외 삭제
  • Loading branch information
FacerAin authored Aug 26, 2024
2 parents 1e51dde + eb43f82 commit 8809cdd
Showing 1 changed file with 11 additions and 16 deletions.
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

0 comments on commit 8809cdd

Please sign in to comment.