From b8e3a757fa6dff90ba0f56a97d4b6fb098de1916 Mon Sep 17 00:00:00 2001 From: Mybread2 Date: Thu, 31 Jul 2025 12:03:00 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=82=AC=EC=9A=A9=EC=9E=90=20=ED=8F=89?= =?UTF-8?q?=EA=B0=80=20=EA=B8=B0=EB=8A=A5=EC=9D=98=20=EA=B0=99=EC=9D=80=20?= =?UTF-8?q?=EB=AA=A8=EC=9E=84=20=EC=B0=B8=EA=B0=80=EC=9E=90=20=EA=B2=80?= =?UTF-8?q?=EC=A6=9D=20=EC=98=A4=EB=A5=98=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - MeetingClient.getParticipantIds에서 ParticipantClientResponseDto 타입 매핑 수정 - userId 필드를 participantId로 올바르게 매핑하여 빈 배열 반환 문제 해결 - 같은 모임 참가자간 평가 기능 정상 작동 확인 --- .../user/application/UserServiceImpl.java | 14 +++++ .../client/meeting/MeetingClient.java | 60 +++++++++++++------ .../dto/ParticipantClientResponseDto.java | 2 +- 3 files changed, 58 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/example/momo/domain/user/application/UserServiceImpl.java b/src/main/java/com/example/momo/domain/user/application/UserServiceImpl.java index 5b6a7876..59daa5c0 100644 --- a/src/main/java/com/example/momo/domain/user/application/UserServiceImpl.java +++ b/src/main/java/com/example/momo/domain/user/application/UserServiceImpl.java @@ -348,16 +348,30 @@ private void validateSameMeetingParticipants(Long reviewerId, Long targetUserId, // 참가자 ID 목록만 조회 (현재 Meeting API가 제공하는 방식) List participantIds = meetingClient.getParticipantIds(meetingId); + // 디버그 로그 추가 + log.info("=== 모임 참가자 검증 시작 ==="); + log.info("meetingId: {}", meetingId); + log.info("reviewerId: {}", reviewerId); + log.info("targetUserId: {}", targetUserId); + log.info("participantIds from API: {}", participantIds); + if (participantIds == null || participantIds.isEmpty()) { + log.error("참가자 목록이 비어있음!"); throw new UserException(UserErrorCode.NOT_SAME_MEETING_PARTICIPANTS); } boolean reviewerParticipated = participantIds.contains(reviewerId); boolean targetParticipated = participantIds.contains(targetUserId); + log.info("reviewerParticipated: {}", reviewerParticipated); + log.info("targetParticipated: {}", targetParticipated); + if (!reviewerParticipated || !targetParticipated) { + log.error("참가 검증 실패!"); throw new UserException(UserErrorCode.NOT_SAME_MEETING_PARTICIPANTS); } + + log.info("=== 모임 참가자 검증 완료 ==="); } @Override diff --git a/src/main/java/com/example/momo/global/infrastructure/client/meeting/MeetingClient.java b/src/main/java/com/example/momo/global/infrastructure/client/meeting/MeetingClient.java index 41e22cce..0adf96a7 100644 --- a/src/main/java/com/example/momo/global/infrastructure/client/meeting/MeetingClient.java +++ b/src/main/java/com/example/momo/global/infrastructure/client/meeting/MeetingClient.java @@ -1,6 +1,7 @@ package com.example.momo.global.infrastructure.client.meeting; import java.time.Duration; +import java.time.LocalDateTime; import java.util.List; import java.util.Objects; @@ -18,8 +19,6 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import java.time.LocalDateTime; - @Slf4j @Component @RequiredArgsConstructor @@ -111,40 +110,66 @@ public List getParticipants(Long meetingId) { } /** - * 참가자 ID 목록 조회 (기존 API 그대로 사용) - * 현재 Meeting API는 List 참가자 ID만 반환함 + * 참가자 ID 목록 조회 - UserService에서 평가 검증용으로 사용 + * Meeting API에서 ParticipantResponseDto 리스트를 받아서 userId만 추출 */ public List getParticipantIds(Long meetingId) { try { - ApiResponse> response = webClient + log.info("=== MeetingClient.getParticipantIds 시작 ==="); + log.info("요청 meetingId: {}", meetingId); + log.info("요청 URL: {}", MEETING_SERVICE_BASE_URI + "/" + meetingId + "/participants"); + + ApiResponse> response = webClient .get() .uri(MEETING_SERVICE_BASE_URI + "/{meetingId}/participants", meetingId) .retrieve() - .bodyToMono(new ParameterizedTypeReference>>() { + .bodyToMono(new ParameterizedTypeReference>>() { }) .timeout(REQUEST_TIMEOUT) .block(); - if (response == null || !response.isSuccess()) { + log.info("API 응답 전체: {}", response); + + if (response == null) { + log.error("응답이 null!"); return List.of(); } - log.debug("참석자 ID 목록 조회 성공: meetingId={}, count={}", meetingId, response.getData().size()); - return response.getData(); + if (!response.isSuccess()) { + log.error("응답 실패: success={}, message={}", response.isSuccess(), response.getMessage()); + return List.of(); + } - } catch (WebClientResponseException e) { - if (e.getStatusCode().value() == 404) { - log.debug("참석자 목록을 찾을 수 없습니다: meetingId={}", meetingId); + if (response.getData() == null) { + log.error("응답 데이터가 null!"); return List.of(); } - log.error("참석자 목록 조회 실패: meetingId={}, status={}, error={}", - meetingId, e.getStatusCode(), e.getMessage()); - throw new MeetingClientException("참석자 목록 조회 중 오류가 발생했습니다: " + e.getMessage()); + log.info("응답 데이터 크기: {}", response.getData().size()); + log.info("응답 데이터 내용: {}", response.getData()); + + List participantIds = response.getData().stream() + .map(participant -> { + log.info("참가자 정보: id={}, meetingId={}, participantId={}, attendance={}", + participant.getId(), participant.getMeetingId(), + participant.getParticipantId(), + participant.isAttendanceStatus()); // getUserId() -> getParticipantId() + return participant.getParticipantId(); // getUserId() -> getParticipantId() + }) + .toList(); + + log.info("최종 추출된 participantIds: {}", participantIds); + log.info("=== MeetingClient.getParticipantIds 완료 ==="); + return participantIds; + + } catch (Exception e) { + log.error("=== MeetingClient.getParticipantIds 오류 ===", e); + return List.of(); } } - public ParticipantCountClientResponseDto getParticipantCount(Long meetingId, Boolean attendance, LocalDateTime createdAt) { + public ParticipantCountClientResponseDto getParticipantCount(Long meetingId, Boolean attendance, + LocalDateTime createdAt) { try { ApiResponse response = webClient .get() @@ -154,7 +179,8 @@ public ParticipantCountClientResponseDto getParticipantCount(Long meetingId, Boo .queryParam("createdAt", createdAt) .build(meetingId)) .retrieve() - .bodyToMono(new ParameterizedTypeReference>() {}) + .bodyToMono(new ParameterizedTypeReference>() { + }) .timeout(REQUEST_TIMEOUT) .block(); diff --git a/src/main/java/com/example/momo/global/infrastructure/client/meeting/dto/ParticipantClientResponseDto.java b/src/main/java/com/example/momo/global/infrastructure/client/meeting/dto/ParticipantClientResponseDto.java index 8b9d906f..da206b33 100644 --- a/src/main/java/com/example/momo/global/infrastructure/client/meeting/dto/ParticipantClientResponseDto.java +++ b/src/main/java/com/example/momo/global/infrastructure/client/meeting/dto/ParticipantClientResponseDto.java @@ -10,6 +10,6 @@ public class ParticipantClientResponseDto { private Long id; private Long meetingId; - private Long userId; + private Long participantId; private boolean attendanceStatus; }