Skip to content

Commit

Permalink
[FIX] 플그 마이페이지 내 모임 조회 API, 204 status code 시 성공 response body로 내려가도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
yeseul106 committed Mar 22, 2024
1 parent 87cd589 commit 9bcf55c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")})
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -43,21 +41,22 @@ public MeetingV2GetAllMeetingByOrgUserDto getAllMeetingByOrgUser(
int page = queryDto.getPage();
int take = queryDto.getTake();

User user = userRepository.findByOrgIdOrThrow(queryDto.getOrgUserId());

List<MeetingV2GetAllMeetingByOrgUserMeetingDto> 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> user = userRepository.findByOrgId(queryDto.getOrgUserId());
List<MeetingV2GetAllMeetingByOrgUserMeetingDto> 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<MeetingV2GetAllMeetingByOrgUserMeetingDto> pagedUserJoinedList =
Expand Down

0 comments on commit 9bcf55c

Please sign in to comment.