Skip to content

Commit

Permalink
Merge pull request #27 from lotteon2/fix/auction-history-with-front
Browse files Browse the repository at this point in the history
[FIX] response whole data
  • Loading branch information
wakkpu authored Jan 16, 2024
2 parents c9ed7be + be963eb commit 9f152bb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public class AuctionHistory implements Comparable<AuctionHistory> {
)
private String auctionId;

@DynamoDBAttribute(attributeName = "auction_name")
private String auctionName;

@DynamoDBAttribute(attributeName = "auction_product_id")
private Long auctionProductId;

Expand Down Expand Up @@ -77,6 +80,7 @@ public class AuctionHistory implements Comparable<AuctionHistory> {
public static AuctionHistory create(
String memberId,
String auctionId,
String auctionName,
Long auctionProductId,
String auctionProductImg,
String auctionProductName,
Expand All @@ -90,6 +94,7 @@ public static AuctionHistory create(
return AuctionHistory.builder()
.memberId(memberId)
.auctionId(auctionId)
.auctionName(auctionName)
.auctionProductId(auctionProductId)
.auctionProductImg(auctionProductImg)
.auctionProductName(auctionProductName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.springframework.data.domain.Page;

import java.util.List;
import java.util.stream.Collectors;

@Getter
@Builder
Expand All @@ -17,51 +16,13 @@
public class ReadAuctionHistoryPageResponse {
private long totalElements;
private int totalPages;
private List<ReadAuctionHistoryResponse> responses;
private List<AuctionHistory> responses;

public static ReadAuctionHistoryPageResponse of(Page<AuctionHistory> histories) {
return ReadAuctionHistoryPageResponse.builder()
.totalPages(histories.getTotalPages())
.totalPages(histories.getTotalPages())
.responses(histories.stream()
.map(ReadAuctionHistoryResponse::of)
.collect(Collectors.toList()))
.responses(histories.toList())
.build();
}

@Getter
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class ReadAuctionHistoryResponse {
private String id;
private String auctionId;
private Long auctionProductId;
private String auctionProductImg;
private String auctionProductName;
private Long auctionProductSizeId;
private String auctionProductSizeName;
private boolean isWinner;
private boolean isPaid;
private Long amountToPay;
private Long memberHighestBid;
private Long auctionWinnerBid;

public static ReadAuctionHistoryResponse of(AuctionHistory auctionHistory) {
return ReadAuctionHistoryResponse.builder()
.id(auctionHistory.getId())
.auctionId(auctionHistory.getAuctionId())
.auctionProductId(auctionHistory.getAuctionProductId())
.auctionProductImg(auctionHistory.getAuctionProductImg())
.auctionProductName(auctionHistory.getAuctionProductName())
.auctionProductSizeId(auctionHistory.getAuctionProductSizeId())
.auctionProductSizeName(auctionHistory.getAuctionProductSizeName())
.isWinner(auctionHistory.isWinner())
.isPaid(auctionHistory.isPaid())
.amountToPay(auctionHistory.getAmountToPay())
.memberHighestBid(auctionHistory.getMemberHighestBid())
.auctionWinnerBid(auctionHistory.getAuctionWinnerBid())
.build();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void auctionHistoryCreateTest() {
AuctionHistory history = AuctionHistory.create(
"1",
"TEST",
"",
1L,
"img.png",
"name",
Expand All @@ -72,23 +73,23 @@ void auctionHistoryCreateTest() {
void findAuctionHistoryListTests() {
List<AuctionHistory> histories = List.of(
AuctionHistory.create(
"1", "TEST", 1L, "img.png", "name", 1L,
"1", "TEST", "", 1L, "img.png", "name", 1L,
"size", true, 10000L, 1000L, 1000L
),
AuctionHistory.create(
"1", "TEST2", 2L, "img.png", "name", 1L,
"1", "TEST2", "",2L, "img.png", "name", 1L,
"size", false, 0L, 100L, 10000L
),
AuctionHistory.create(
"1", "TEST3", 3L, "img.png", "name", 1L,
"1", "TEST3", "",3L, "img.png", "name", 1L,
"size", false, 0L, 1000L, 10000L
),
AuctionHistory.create(
"2", "TEST", 1L, "img.png", "name", 1L,
"2", "TEST", "",1L, "img.png", "name", 1L,
"size", true, 10000L, 1000L, 1000L
),
AuctionHistory.create(
"2", "TEST2", 2L, "img.png", "name", 1L,
"2", "TEST2", "",2L, "img.png", "name", 1L,
"size", false, 0L, 100L, 10000L
)
);
Expand Down

0 comments on commit 9f152bb

Please sign in to comment.