Skip to content

Commit

Permalink
NABI-205--refactor : 서비스 1번 호출하게 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
born-A committed Nov 14, 2023
1 parent 4e2c612 commit 03542d1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,7 @@ public ResponseEntity<SingleResult<CardListResponseDTO<SuggestionAvailableCardRe
CardListResponseDTO<SuggestionAvailableCardResponseDTO> cardListResponseDTO
= cardService.getSuggestionAvailableCards(token, targetCardId);


List<SuggestionAvailableCardResponseDTO> suggestionResultCardList = cardService.getSuggestionResultCardList(
targetCardId,
cardListResponseDTO.cardList()
);

CardListResponseDTO<SuggestionAvailableCardResponseDTO> listResponseDTO =
new CardListResponseDTO<>(suggestionResultCardList);

return ResponseEntity.ok(ResponseFactory.getSingleResult(listResponseDTO));
return ResponseEntity.ok(ResponseFactory.getSingleResult(cardListResponseDTO));
}

@PutMapping("/{cardId}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ public List<SuggestionAvailableCardResponseDTO> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ public CardListReadPagingResponseDTO getCardsByCondition(
@Transactional(readOnly = true)
public CardListResponseDTO<SuggestionAvailableCardResponseDTO> 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())) {
Expand All @@ -190,7 +190,10 @@ public CardListResponseDTO<SuggestionAvailableCardResponseDTO> getSuggestionAvai
suggestionTargetCard.getCardId()
);

return new CardListResponseDTO<>(cardListResponse);
List<SuggestionAvailableCardResponseDTO> suggestionResultCardList =
getSuggestionResultCardList(suggestionTargetCard.getCardId(), cardListResponse);

return new CardListResponseDTO<>(suggestionResultCardList);
}

@Transactional(readOnly = true)
Expand Down

0 comments on commit 03542d1

Please sign in to comment.