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 afbd0f3c..2b98eb6d 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 @@ -130,9 +130,9 @@ 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), - suggestion.toCard.cardId.eq(targetCardId).or(suggestion.toCard.cardId.isNull())) + .where(card.user.userId.eq(userId)) + .distinct() + .on(suggestion.toCard.cardId.eq(targetCardId)) .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 31fd878a..ba8d13be 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 @@ -225,8 +225,10 @@ public CardListResponseDTO getSuggestionAvailableCard Long targetCardId ) { Long userId = checkService.parseToken(token); + User requestUser = userRepository.findById(userId) .orElseThrow(() -> new BaseException(ErrorCode.USER_NOT_FOUND)); + Card suggestionTargetCard = cardRepository.findById(targetCardId) .orElseThrow(() -> new BaseException(ErrorCode.CARD_NOT_FOUND)); @@ -315,7 +317,7 @@ public List getSuggestionResultCardList( ) { Card targetCard = cardRepository.findById(targetId) .orElseThrow(() -> new BaseException(ErrorCode.CARD_NOT_FOUND)); - + Boolean pokeAvailable = targetCard.getPokeAvailable(); PriceRange priceRange = targetCard.getItem().getPriceRange(); diff --git a/src/main/java/org/prgrms/nabimarketbe/domain/suggestion/entity/SuggestionType.java b/src/main/java/org/prgrms/nabimarketbe/domain/suggestion/entity/SuggestionType.java index fcdc3ed2..51f0d7d3 100644 --- a/src/main/java/org/prgrms/nabimarketbe/domain/suggestion/entity/SuggestionType.java +++ b/src/main/java/org/prgrms/nabimarketbe/domain/suggestion/entity/SuggestionType.java @@ -5,7 +5,8 @@ import org.prgrms.nabimarketbe.domain.item.entity.Item; public enum SuggestionType { - OFFER( (fromItem, toItem) -> (fromItem.getPriceRange().equals(toItem.getPriceRange())) ), + OFFER( (fromItem, toItem) -> (fromItem.getPriceRange().equals(toItem.getPriceRange()) + || fromItem.getPriceRange().getValue() > toItem.getPriceRange().getValue()) ), POKE( (fromItem, toItem) -> (fromItem.getPriceRange().getValue() < toItem.getPriceRange().getValue()) ); public final BiFunction suggestionValidationFunction;