From 8e44a9a0ebc14045d2e877dfd30dc4c77df99f54 Mon Sep 17 00:00:00 2001 From: choidongkuen Date: Fri, 16 Feb 2024 10:28:53 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=AA=A8=EC=9E=84=20=EC=B0=B8=EC=97=AC?= =?UTF-8?q?=EC=9E=90=20=EC=9E=90=EC=8B=A0=20=ED=8F=AC=ED=95=A8=20=EC=97=AC?= =?UTF-8?q?=EB=B6=80=20=ED=99=95=EC=9D=B8=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80(#228)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../meeting/service/MeetingService.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) 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("모임에 참여하지 않은 회원입니다."); + } + } }