diff --git a/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java b/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java index 86425d8..e3f9f54 100644 --- a/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java +++ b/src/main/java/com/example/api/matching/adapter/in/rest/MatchingController.java @@ -13,6 +13,7 @@ import com.example.api.member.application.port.in.AddMemberChatRoomUsecase; import com.example.api.user.application.port.in.FindUserUsecase; import com.example.api.user.dto.FindUserDto; +import com.example.api.user.dto.FindUserInfoDto; import com.example.api.user.dto.UserAuthorityCheckDto; import com.example.api.user.type.UserRoleEnum; import io.swagger.v3.oas.annotations.Operation; @@ -122,7 +123,7 @@ public Optional getMatchingById(@PathVariable Long matchingId) */ @Operation(summary = "Get pending user list of matching", description = "매칭의 대기자 목록을 조회한다.") @GetMapping("/matching/{matchingId}/pending") - public List getPendingUserList(@PathVariable Long matchingId) { + public List getPendingUserList(@PathVariable Long matchingId) { return matchingApplicationUsecase.getByMatchingIdIsAndStateEquals(matchingId, ApplicationStateEnum.Pending); } @@ -133,7 +134,7 @@ public List getPendingUserList(@PathVariable Long matchingId) { */ @Operation(summary = "Get approved user list of matching", description = "매칭의 참가자 목록을 조회한다.") @GetMapping("/matching/{matchingId}/approved") - public List getApprovedUserList(@PathVariable Long matchingId) { + public List getApprovedUserList(@PathVariable Long matchingId) { return matchingApplicationUsecase.getByMatchingIdIsAndStateEquals(matchingId, ApplicationStateEnum.Approved); } diff --git a/src/main/java/com/example/api/matching/application/port/in/MatchingApplicationUsecase.java b/src/main/java/com/example/api/matching/application/port/in/MatchingApplicationUsecase.java index 26fdd4f..16b6050 100644 --- a/src/main/java/com/example/api/matching/application/port/in/MatchingApplicationUsecase.java +++ b/src/main/java/com/example/api/matching/application/port/in/MatchingApplicationUsecase.java @@ -4,7 +4,7 @@ import com.example.api.matching.domain.MatchingApplication; import com.example.api.matching.dto.SaveMatchingApplicationDto; import com.example.api.matching.dto.FindMatchingDto; -import com.example.api.user.dto.FindUserDto; +import com.example.api.user.dto.FindUserInfoDto; import java.util.List; import java.util.UUID; @@ -12,7 +12,7 @@ public interface MatchingApplicationUsecase { MatchingApplication createMatchingApplicationData(UUID userId, SaveMatchingApplicationDto matchingApplicationDto); List getByUserIdIsAndStateEquals(UUID userId, ApplicationStateEnum state); - List getByMatchingIdIsAndStateEquals(Long matchingId, ApplicationStateEnum state); + List getByMatchingIdIsAndStateEquals(Long matchingId, ApplicationStateEnum state); String getUserStatus(UUID userId, Long matchingId); void approveMatchingApplication(SaveMatchingApplicationDto matchingApplicationPK); void declineMatchingApplication(SaveMatchingApplicationDto matchingApplicationPK); diff --git a/src/main/java/com/example/api/matching/service/MatchingApplicationService.java b/src/main/java/com/example/api/matching/service/MatchingApplicationService.java index 824c6b3..e16482c 100644 --- a/src/main/java/com/example/api/matching/service/MatchingApplicationService.java +++ b/src/main/java/com/example/api/matching/service/MatchingApplicationService.java @@ -5,6 +5,7 @@ import com.example.api.fcm.service.FcmService; import com.example.api.matching.adapter.out.persistence.MatchingApplicationEntity; import com.example.api.matching.adapter.out.persistence.MatchingApplicationPK; +import com.example.api.matching.adapter.out.persistence.MatchingEntity; import com.example.api.matching.adapter.out.persistence.MatchingMapperInterface; import com.example.api.matching.application.port.in.MatchingApplicationUsecase; import com.example.api.matching.application.port.out.FindMatchingPort; @@ -12,9 +13,11 @@ import com.example.api.matching.domain.MatchingApplication; import com.example.api.matching.dto.FindMatchingDto; import com.example.api.matching.dto.SaveMatchingApplicationDto; +import com.example.api.user.adapter.out.persistence.UserEntity; import com.example.api.user.adapter.out.persistence.UserMapperInterface; import com.example.api.user.application.port.out.FindUserPort; import com.example.api.user.dto.FindUserDto; +import com.example.api.user.dto.FindUserInfoDto; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -54,17 +57,27 @@ public List getByUserIdIsAndStateEquals(UUID userId, Applicatio List matchingPairList = matchingApplicationPort.getByUserIdIsAndStateEquals(userId, state); List matchingData = new ArrayList<>(); for (MatchingApplicationEntity matchingPair: matchingPairList) { - matchingData.add(matchingMapper.toDto(findMatchingPort.getByMatchingId(matchingPair.getMatchingId()).orElseThrow())); + Optional matchingEntity = findMatchingPort.getByMatchingId(matchingPair.getMatchingId()); + if (matchingEntity.isEmpty()) { + log.warn("MatchingApplicationService::getByUserIdIsAndStateEquals: Matching with ID {} doesn't exist", matchingPair.getMatchingId()); + } else { + matchingData.add(matchingMapper.toDto(matchingEntity.get())); + } } return matchingData; } @Override - public List getByMatchingIdIsAndStateEquals(Long matchingId, ApplicationStateEnum state) { + public List getByMatchingIdIsAndStateEquals(Long matchingId, ApplicationStateEnum state) { List matchingPairList = matchingApplicationPort.getByMatchingIdIsAndStateEquals(matchingId, state); - List userData = new ArrayList<>(); + List userData = new ArrayList<>(); for (MatchingApplicationEntity matchingPair: matchingPairList) { - userData.add(userMapper.toDto(findUserPort.getByUserId(matchingPair.getUserId()).orElseThrow())); + Optional userEntity = findUserPort.getByUserId(matchingPair.getUserId()); + if (userEntity.isEmpty()) { + log.warn("MatchingApplicationService::getByMatchingIdIsAndStateEquals: User with ID {} doesn't exist", matchingPair.getUserId()); + } else { + userData.add(userMapper.toInfoDto(userEntity.get())); + } } return userData; } diff --git a/src/main/java/com/example/api/user/adapter/out/persistence/UserMapperInterface.java b/src/main/java/com/example/api/user/adapter/out/persistence/UserMapperInterface.java index d273a96..258e37e 100644 --- a/src/main/java/com/example/api/user/adapter/out/persistence/UserMapperInterface.java +++ b/src/main/java/com/example/api/user/adapter/out/persistence/UserMapperInterface.java @@ -2,10 +2,7 @@ import com.example.api.user.domain.CreateUser; import com.example.api.user.domain.User; -import com.example.api.user.dto.CreateUserDto; -import com.example.api.user.dto.FindUserDto; -import com.example.api.user.dto.UpdateUserDto; -import com.example.api.user.dto.UserAuthorityCheckDto; +import com.example.api.user.dto.*; import org.mapstruct.InjectionStrategy; import org.mapstruct.Mapper; import org.mapstruct.Mapping; @@ -24,6 +21,7 @@ public interface UserMapperInterface { User toDomain(UserEntity userEntity); FindUserDto toDto(UserEntity userEntity); FindUserDto toDto(User user); + FindUserInfoDto toInfoDto(UserEntity userEntity); UserAuthorityCheckDto toAuthorityDto(UserEntity userEntity); FindUserDto toDto(UpdateUserDto updateUserDto); } \ No newline at end of file diff --git a/src/main/java/com/example/api/user/dto/FindUserInfoDto.java b/src/main/java/com/example/api/user/dto/FindUserInfoDto.java new file mode 100644 index 0000000..0234077 --- /dev/null +++ b/src/main/java/com/example/api/user/dto/FindUserInfoDto.java @@ -0,0 +1,56 @@ +package com.example.api.user.dto; + +import com.example.api.user.type.UserGenderEnum; +import com.example.api.user.type.UserRoleEnum; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.*; + +import java.time.LocalDateTime; +import java.util.UUID; + +@Getter +@Builder +@ToString +@NoArgsConstructor +@AllArgsConstructor +public class FindUserInfoDto { + @NotBlank + private UUID userId; + + @NotBlank + private String username; + + @NotNull + private UserGenderEnum gender; + + @NotNull + @Min(0) + private Integer age; + + @NotBlank + private String phone; + + @NotNull + private UserRoleEnum role; + + @NotNull + private Boolean blacklist; + + @NotNull + private String stateMessage; + + @NotNull + @Min(0) + private Integer mannerScore; + + @NotNull + private LocalDateTime createdAt; + + @NotNull + private LocalDateTime updatedAt; + + @NotNull + private Boolean isActive; +} \ No newline at end of file