diff --git a/src/main/java/net/teumteum/meeting/service/MeetingService.java b/src/main/java/net/teumteum/meeting/service/MeetingService.java index 99cfc41..5003080 100644 --- a/src/main/java/net/teumteum/meeting/service/MeetingService.java +++ b/src/main/java/net/teumteum/meeting/service/MeetingService.java @@ -12,7 +12,7 @@ import net.teumteum.meeting.domain.Topic; import net.teumteum.meeting.domain.request.CreateMeetingRequest; import net.teumteum.meeting.domain.request.UpdateMeetingRequest; -import net.teumteum.meeting.domain.response.MeetingParticipantsResponse; +import net.teumteum.meeting.domain.response.MeetingParticipantResponse; import net.teumteum.meeting.domain.response.MeetingResponse; import net.teumteum.meeting.domain.response.MeetingsResponse; import net.teumteum.meeting.model.PageDto; @@ -94,7 +94,8 @@ public void deleteMeeting(Long meetingId, Long userId) { } @Transactional(readOnly = true) - public PageDto getMeetingsBySpecification(Pageable pageable, Topic topic, String meetingAreaStreet, + public PageDto getMeetingsBySpecification(Pageable pageable, Topic topic, + String meetingAreaStreet, Long participantUserId, String searchWord, Boolean isBookmarked, Boolean isOpen, Long userId) { Specification spec = MeetingSpecification.withIsOpen(isOpen); @@ -153,13 +154,16 @@ public void cancelParticipant(Long meetingId, Long userId) { } @Transactional(readOnly = true) - public List getParticipants(Long meetingId) { + public List getParticipants(Long meetingId, Long userId) { var existMeeting = getMeeting(meetingId); + checkMeetingContainUser(existMeeting, userId); + return existMeeting.getParticipantUserIds().stream() + .filter(id -> !id.equals(userId)) .map(userConnector::findUserById) .flatMap(Optional::stream) - .map(MeetingParticipantsResponse::of) + .map(MeetingParticipantResponse::of) .toList(); } @@ -207,4 +211,10 @@ public void reportMeeting(Long meetingId, Long userId) { throw new IllegalArgumentException("모임 개설자는 모임을 신고할 수 없습니다."); } } + + private void checkMeetingContainUser(Meeting meeting, Long userId) { + if (!meeting.getParticipantUserIds().contains(userId)) { + throw new IllegalArgumentException("모임에 참여하지 않은 회원입니다."); + } + } }