diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/card/api/CardController.java b/src/main/java/org/prgrms/nabimarketbe/domain/card/api/CardController.java index 71e33ac4..3a59f663 100644 --- a/src/main/java/org/prgrms/nabimarketbe/domain/card/api/CardController.java +++ b/src/main/java/org/prgrms/nabimarketbe/domain/card/api/CardController.java @@ -85,16 +85,7 @@ public ResponseEntity cardListResponseDTO = cardService.getSuggestionAvailableCards(token, targetCardId); - - List suggestionResultCardList = cardService.getSuggestionResultCardList( - targetCardId, - cardListResponseDTO.cardList() - ); - - CardListResponseDTO listResponseDTO = - new CardListResponseDTO<>(suggestionResultCardList); - - return ResponseEntity.ok(ResponseFactory.getSingleResult(listResponseDTO)); + return ResponseEntity.ok(ResponseFactory.getSingleResult(cardListResponseDTO)); } @PutMapping("/{cardId}") diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/response/CardDetail.java b/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/response/CardDetail.java index 9b63dfd7..99a07bc6 100644 --- a/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/response/CardDetail.java +++ b/src/main/java/org/prgrms/nabimarketbe/domain/card/dto/response/CardDetail.java @@ -52,7 +52,7 @@ public static CardDetail of( .tradeType(card.getTradeType()) .tradeArea(card.getTradeArea()) .dibsCount(card.getDibCount()) - .isMyDib() //TODO + .isMyDib(true) //TODO .images(cardImages) .build(); } diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/card/repository/CardRepositoryImpl.java b/src/main/java/org/prgrms/nabimarketbe/domain/card/repository/CardRepositoryImpl.java index 4e8b0fa2..842d090a 100644 --- a/src/main/java/org/prgrms/nabimarketbe/domain/card/repository/CardRepositoryImpl.java +++ b/src/main/java/org/prgrms/nabimarketbe/domain/card/repository/CardRepositoryImpl.java @@ -133,8 +133,8 @@ public List getSuggestionAvailableCards( .from(card) .leftJoin(suggestion).on(suggestion.fromCard.cardId.eq(card.cardId)) .leftJoin(suggestion).on(suggestion.toCard.cardId.eq(targetCardId)) - .where(card.user.userId.eq(userId)) - .distinct() + .where(card.user.userId.eq(userId), + suggestion.toCard.cardId.eq(targetCardId).or(suggestion.toCard.cardId.isNull())) .fetch(); return cardList; diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/card/service/CardService.java b/src/main/java/org/prgrms/nabimarketbe/domain/card/service/CardService.java index 766c104e..2d008036 100644 --- a/src/main/java/org/prgrms/nabimarketbe/domain/card/service/CardService.java +++ b/src/main/java/org/prgrms/nabimarketbe/domain/card/service/CardService.java @@ -174,11 +174,11 @@ public CardListReadPagingResponseDTO getCardsByCondition( @Transactional(readOnly = true) public CardListResponseDTO getSuggestionAvailableCards( String token, - Long cardId + Long targetCardId ) { User requestUser = userRepository.findById(checkService.parseToken(token)) .orElseThrow(() -> new BaseException(ErrorCode.USER_NOT_FOUND)); - Card suggestionTargetCard = cardRepository.findById(cardId) + Card suggestionTargetCard = cardRepository.findById(targetCardId) .orElseThrow(() -> new BaseException(ErrorCode.CARD_NOT_FOUND)); if (requestUser.getUserId().equals(suggestionTargetCard.getUser().getUserId())) { @@ -190,7 +190,10 @@ public CardListResponseDTO getSuggestionAvai suggestionTargetCard.getCardId() ); - return new CardListResponseDTO<>(cardListResponse); + List suggestionResultCardList = + getSuggestionResultCardList(suggestionTargetCard.getCardId(), cardListResponse); + + return new CardListResponseDTO<>(suggestionResultCardList); } @Transactional(readOnly = true)