Skip to content

Commit

Permalink
Merge pull request #54 from dnd-side-project/feat/meeting-closed
Browse files Browse the repository at this point in the history
[Feat/#50] 회의 종료시 안건 상태 관리 및 권한 확인 작업 추가
  • Loading branch information
Starlight258 authored Feb 19, 2024
2 parents 4e9e8ed + 29bd9e7 commit 347067c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void cancelAgenda(Long meetingId, Long agendaId) {
Agenda agenda = agendaRepository.findByIdAndMeetingId(agendaId, meetingId)
.orElseThrow(() -> new NotFoundError(ErrorCode.RESOURCE_NOT_FOUND,
Collections.singletonMap("AgendaId", "Agenda not found")));
agenda.delete();
agenda.cancel();
}


Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/dnd/timeet/agenda/domain/Agenda.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ private void validateTransition(AgendaStatus... validPreviousStatuses) {
Collections.singletonMap("AgendaStatus", "Invalid status transition"));
}

public void cancelAgenda() {
public void cancel() {
this.status = AgendaStatus.CANCELED;
this.delete();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package org.dnd.timeet.common.exception;


import java.util.Map;
import lombok.Getter;
import org.springframework.http.HttpStatus;

import java.util.Map;

/**
* HTTP 상태 코드 403 (Forbidden) : 금지됨 인증은 되었지만, 리소스에 접근할 권한이 없을때 발생합니다.
* HTTP 상태 코드 403 (Forbidden) : 금지됨. 인증은 되었지만, 리소스에 접근할 권한이 없을때 발생합니다.
*/
@Getter
public class ForbiddenError extends ApiException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@

import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.dnd.timeet.agenda.domain.AgendaRepository;
import org.dnd.timeet.agenda.domain.AgendaStatus;
import org.dnd.timeet.agenda.domain.AgendaType;
import org.dnd.timeet.agenda.dto.AgendaReportInfoResponse;
import org.dnd.timeet.common.exception.BadRequestError;
import org.dnd.timeet.common.exception.ForbiddenError;
import org.dnd.timeet.common.exception.NotFoundError;
import org.dnd.timeet.common.exception.NotFoundError.ErrorCode;
import org.dnd.timeet.meeting.domain.Meeting;
Expand Down Expand Up @@ -49,12 +51,27 @@ public Meeting createMeeting(MeetingCreateRequest createDto, Member member) {
return meeting;
}

public void endMeeting(Long meetingId) {
public void endMeeting(Long meetingId, Long memberId) {
Meeting meeting = meetingRepository.findById(meetingId)
.orElseThrow(() -> new NotFoundError(NotFoundError.ErrorCode.RESOURCE_NOT_FOUND,
Collections.singletonMap("MeetingId", "Meeting not found")));
// 회의의 방장인지 확인
if (!Objects.equals(meeting.getHostMember().getId(), memberId)) {
throw new ForbiddenError(ForbiddenError.ErrorCode.ROLE_BASED_ACCESS_ERROR,
Collections.singletonMap("MemberId", "Member is not the host of the meeting"));
}

meeting.endMeeting();
// 회의에서 진행중인 안건들도 모두 종료되도록 하기
agendaRepository.findByMeetingId(meetingId)
.forEach(agenda -> {
if (agenda.getStatus().equals(AgendaStatus.INPROGRESS) ||
agenda.getStatus().equals(AgendaStatus.PAUSED)) {
agenda.complete();
} else if (agenda.getStatus().equals(AgendaStatus.PENDING)) {
agenda.cancel();
}
});
}

public Meeting addParticipantToMeeting(Long meetingId, Member member) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import org.dnd.timeet.common.security.CustomUserDetails;
import org.dnd.timeet.common.security.annotation.ReqUser;
import org.dnd.timeet.common.utils.ApiUtils;
import org.dnd.timeet.common.utils.ApiUtils.ApiResult;
import org.dnd.timeet.meeting.application.MeetingService;
Expand All @@ -17,6 +18,7 @@
import org.dnd.timeet.meeting.dto.MeetingRemainingTimeResponse;
import org.dnd.timeet.meeting.dto.MeetingReportInfoResponse;
import org.dnd.timeet.meeting.dto.MeetingReportResponse;
import org.dnd.timeet.member.domain.Member;
import org.dnd.timeet.member.dto.MemberInfoListResponse;
import org.dnd.timeet.member.dto.MemberInfoResponse;
import org.springframework.http.ResponseEntity;
Expand Down Expand Up @@ -67,8 +69,10 @@ public ResponseEntity<ApiResult<MeetingCreateResponse>> attendMeeting(
@PatchMapping("/{meeting-id}/end")
@Operation(summary = "회의 종료", description = "회의를 종료한다.")
public ResponseEntity<ApiResult<MeetingReportResponse>> closeMeeting(
@PathVariable("meeting-id") Long meetingId) {
meetingService.endMeeting(meetingId);
@PathVariable("meeting-id") Long meetingId,
@ReqUser Member member) {
meetingService.endMeeting(meetingId, member.getId());

MeetingReportInfoResponse meetingReportInfoResponse = meetingService.createReport(meetingId);
MeetingReportResponse meetingReportResponse = new MeetingReportResponse(meetingReportInfoResponse);

Expand Down

0 comments on commit 347067c

Please sign in to comment.