Skip to content

Commit

Permalink
♻️ Refactor[#25]: PointHomeResponse에 userName 반환값 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kduoh99 committed Nov 23, 2024
1 parent b07a409 commit 70d96e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@

@Builder
public record PointHomeResponse(
String userName,
Integer balance, // 페이잔액
Integer totalCards, //사용자가 보유한 모든 지역 카드 수
List<CardInfo> cards,
List<PaylistInfo> paylistInfos
) {
public static PointHomeResponse of(Pay pay, Integer totalCards, List<CardInfo> cards, List<PaylistInfo> paylistInfos){
public static PointHomeResponse of(String userName, Pay pay, Integer totalCards, List<CardInfo> cards,
List<PaylistInfo> paylistInfos) {
return PointHomeResponse.builder()
.userName(userName)
.balance(pay.getTotalPay())
.totalCards(totalCards)
.cards(cards)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public PointHomeResponse getHome(Principal principal) {
.map(paylist -> PaylistInfo.of(paylist, paylist.getStore()))
.toList();

return PointHomeResponse.of(pay, cardInfos.size(), cardInfos, paylistInfos);
return PointHomeResponse.of(user.getName(), pay, cardInfos.size(), cardInfos, paylistInfos);
}

@Transactional
Expand Down Expand Up @@ -154,7 +154,7 @@ public PointTransferInfoResponse getPointTransferInfo(Principal principal) {
.map(CardInfo::from)
.toList();

return PointTransferInfoResponse.of(cards.size(),cardInfos);
return PointTransferInfoResponse.of(cards.size(), cardInfos);
}

// 포인트 이전
Expand All @@ -170,7 +170,7 @@ public PointTransferResponse pointTransfer(PointTransferRequest request, Princip

//해당 유저가 가진 카드가 맞는지 검증
if (!Objects.equals(user.getId(), toCard.getUser().getId()) & !Objects.equals(user.getId(),
toCard.getUser().getId())){
toCard.getUser().getId())) {
throw new CardNotFoundException("해당 유저가 보유한 카드가 아닙니다");
}

Expand Down

0 comments on commit 70d96e8

Please sign in to comment.