From 9bcf55cc5ee58ab08bf9085936382d6805890222 Mon Sep 17 00:00:00 2001 From: yeseul106 <20191037@sungshin.ac.kr> Date: Sat, 23 Mar 2024 03:15:49 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20=ED=94=8C=EA=B7=B8=20=EB=A7=88=EC=9D=B4?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=82=B4=20=EB=AA=A8=EC=9E=84=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20API,=20204=20status=20code=20=EC=8B=9C=20?= =?UTF-8?q?=EC=84=B1=EA=B3=B5=20response=20body=EB=A1=9C=20=EB=82=B4?= =?UTF-8?q?=EB=A0=A4=EA=B0=80=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/meeting/v2/MeetingV2Controller.java | 5 ++- .../v2/service/MeetingV2ServiceImpl.java | 35 +++++++++---------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/MeetingV2Controller.java b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/MeetingV2Controller.java index 10deb198..8fde94cf 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/MeetingV2Controller.java +++ b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/MeetingV2Controller.java @@ -7,9 +7,9 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; import java.security.Principal; import java.util.List; +import lombok.RequiredArgsConstructor; import org.sopt.makers.crew.main.common.util.UserUtil; import org.sopt.makers.crew.main.meeting.v2.dto.query.MeetingV2GetAllMeetingByOrgUserQueryDto; import org.sopt.makers.crew.main.meeting.v2.dto.response.MeetingV2GetAllMeetingByOrgUserDto; @@ -34,8 +34,7 @@ public class MeetingV2Controller { @Operation(summary = "플레이그라운드 마이페이지 내 모임 정보 조회") @GetMapping("/org-user") @ResponseStatus(HttpStatus.OK) - @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "성공"), - @ApiResponse(responseCode = "204", description = "참여했던 모임이 없습니다.", content = @Content),}) + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "성공")}) @Parameters({@Parameter(name = "page", description = "페이지, default = 1", example = "1"), @Parameter(name = "take", description = "가져올 데이터 개수, default = 12", example = "50"), @Parameter(name = "orgUserId", description = "플레이그라운드 유저 id", example = "0")}) diff --git a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2ServiceImpl.java b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2ServiceImpl.java index de71c3bd..6cd4a0b5 100644 --- a/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2ServiceImpl.java +++ b/main/src/main/java/org/sopt/makers/crew/main/meeting/v2/service/MeetingV2ServiceImpl.java @@ -1,15 +1,13 @@ package org.sopt.makers.crew.main.meeting.v2.service; -import static org.sopt.makers.crew.main.common.response.ErrorStatus.NO_CONTENT_EXCEPTION; - import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; import java.util.stream.Stream; import lombok.RequiredArgsConstructor; -import org.sopt.makers.crew.main.common.exception.NoContentException; import org.sopt.makers.crew.main.common.pagination.dto.PageMetaDto; import org.sopt.makers.crew.main.common.pagination.dto.PageOptionsDto; import org.sopt.makers.crew.main.entity.apply.Apply; @@ -43,21 +41,22 @@ public MeetingV2GetAllMeetingByOrgUserDto getAllMeetingByOrgUser( int page = queryDto.getPage(); int take = queryDto.getTake(); - User user = userRepository.findByOrgIdOrThrow(queryDto.getOrgUserId()); - - List userJoinedList = Stream - .concat(user.getMeetings().stream(), - applyRepository.findAllByUserIdAndStatus(user.getId(), EnApplyStatus.APPROVE).stream() - .map(apply -> apply.getMeeting())) - .map(meeting -> MeetingV2GetAllMeetingByOrgUserMeetingDto.of(meeting.getId(), - checkMeetingLeader(meeting, user.getId()), meeting.getTitle(), - meeting.getImageURL().get(0).getUrl(), meeting.getCategory().getValue(), - meeting.getMStartDate(), meeting.getMEndDate(), checkActivityStatus(meeting))) - .sorted(Comparator.comparing(MeetingV2GetAllMeetingByOrgUserMeetingDto::getId).reversed()) - .collect(Collectors.toList()); - - if (userJoinedList.isEmpty()) { - throw new NoContentException(NO_CONTENT_EXCEPTION.getErrorCode()); + Optional user = userRepository.findByOrgId(queryDto.getOrgUserId()); + List userJoinedList = new ArrayList<>(); + + if (!user.isEmpty()) { + User existUser = user.get(); + userJoinedList = Stream + .concat(existUser.getMeetings().stream(), + applyRepository.findAllByUserIdAndStatus(existUser.getId(), EnApplyStatus.APPROVE) + .stream() + .map(apply -> apply.getMeeting())) + .map(meeting -> MeetingV2GetAllMeetingByOrgUserMeetingDto.of(meeting.getId(), + checkMeetingLeader(meeting, existUser.getId()), meeting.getTitle(), + meeting.getImageURL().get(0).getUrl(), meeting.getCategory().getValue(), + meeting.getMStartDate(), meeting.getMEndDate(), checkActivityStatus(meeting))) + .sorted(Comparator.comparing(MeetingV2GetAllMeetingByOrgUserMeetingDto::getId).reversed()) + .collect(Collectors.toList()); } List pagedUserJoinedList =