Skip to content

Commit

Permalink
Merge pull request #164 from swm-nodriversomabus/BUS-205-Controller-r…
Browse files Browse the repository at this point in the history
…eturn-userId

feat(BE): 매칭 대기자/참가자 API의 userId 반환 BUS-205-Controller-return-userId #160
  • Loading branch information
Lemonade255 authored Oct 30, 2023
2 parents b93395e + 860099e commit e7569e0
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -122,7 +123,7 @@ public Optional<FindMatchingDto> getMatchingById(@PathVariable Long matchingId)
*/
@Operation(summary = "Get pending user list of matching", description = "매칭의 대기자 목록을 조회한다.")
@GetMapping("/matching/{matchingId}/pending")
public List<FindUserDto> getPendingUserList(@PathVariable Long matchingId) {
public List<FindUserInfoDto> getPendingUserList(@PathVariable Long matchingId) {
return matchingApplicationUsecase.getByMatchingIdIsAndStateEquals(matchingId, ApplicationStateEnum.Pending);
}

Expand All @@ -133,7 +134,7 @@ public List<FindUserDto> getPendingUserList(@PathVariable Long matchingId) {
*/
@Operation(summary = "Get approved user list of matching", description = "매칭의 참가자 목록을 조회한다.")
@GetMapping("/matching/{matchingId}/approved")
public List<FindUserDto> getApprovedUserList(@PathVariable Long matchingId) {
public List<FindUserInfoDto> getApprovedUserList(@PathVariable Long matchingId) {
return matchingApplicationUsecase.getByMatchingIdIsAndStateEquals(matchingId, ApplicationStateEnum.Approved);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
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;

public interface MatchingApplicationUsecase {
MatchingApplication createMatchingApplicationData(UUID userId, SaveMatchingApplicationDto matchingApplicationDto);
List<FindMatchingDto> getByUserIdIsAndStateEquals(UUID userId, ApplicationStateEnum state);
List<FindUserDto> getByMatchingIdIsAndStateEquals(Long matchingId, ApplicationStateEnum state);
List<FindUserInfoDto> getByMatchingIdIsAndStateEquals(Long matchingId, ApplicationStateEnum state);
String getUserStatus(UUID userId, Long matchingId);
void approveMatchingApplication(SaveMatchingApplicationDto matchingApplicationPK);
void declineMatchingApplication(SaveMatchingApplicationDto matchingApplicationPK);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
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;
import com.example.api.matching.application.port.out.MatchingApplicationPort;
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;
Expand Down Expand Up @@ -54,17 +57,27 @@ public List<FindMatchingDto> getByUserIdIsAndStateEquals(UUID userId, Applicatio
List<MatchingApplicationEntity> matchingPairList = matchingApplicationPort.getByUserIdIsAndStateEquals(userId, state);
List<FindMatchingDto> matchingData = new ArrayList<>();
for (MatchingApplicationEntity matchingPair: matchingPairList) {
matchingData.add(matchingMapper.toDto(findMatchingPort.getByMatchingId(matchingPair.getMatchingId()).orElseThrow()));
Optional<MatchingEntity> 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<FindUserDto> getByMatchingIdIsAndStateEquals(Long matchingId, ApplicationStateEnum state) {
public List<FindUserInfoDto> getByMatchingIdIsAndStateEquals(Long matchingId, ApplicationStateEnum state) {
List<MatchingApplicationEntity> matchingPairList = matchingApplicationPort.getByMatchingIdIsAndStateEquals(matchingId, state);
List<FindUserDto> userData = new ArrayList<>();
List<FindUserInfoDto> userData = new ArrayList<>();
for (MatchingApplicationEntity matchingPair: matchingPairList) {
userData.add(userMapper.toDto(findUserPort.getByUserId(matchingPair.getUserId()).orElseThrow()));
Optional<UserEntity> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
56 changes: 56 additions & 0 deletions src/main/java/com/example/api/user/dto/FindUserInfoDto.java
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit e7569e0

Please sign in to comment.