Skip to content

Commit

Permalink
feat: Auction 생성자에서 경매 상태를 지정할 수 없도록 수정
Browse files Browse the repository at this point in the history
- AuctionStatus는 WAITING을 기본값으로 가진다.
- Auction의 ID는 setter를 통해 지정할 수 있도록 수정한다.
  • Loading branch information
chhs2131 committed Aug 13, 2024
1 parent 8de6a2c commit af11240
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ private Auction(final Long id, final ZonedDateTime startedAt, final Long sellerI
final long maximumPurchaseLimitCount, final PricePolicy pricePolicy,
final Duration variationDuration,
final ZonedDateTime finishedAt,
final boolean isShowStock,
final AuctionStatus auctionStatus
final boolean isShowStock
) {
this.id = id;
this.startedAt = startedAt;
Expand All @@ -45,12 +44,7 @@ private Auction(final Long id, final ZonedDateTime startedAt, final Long sellerI
this.variationDuration = variationDuration;
this.finishedAt = finishedAt;
this.isShowStock = isShowStock;

if (auctionStatus == null) {
this.status = AuctionStatus.WAITING;
} else {
this.status = auctionStatus;
}
this.status = AuctionStatus.WAITING;

pricePolicy.validate(originPrice);
}
Expand Down Expand Up @@ -113,4 +107,8 @@ public void updatePricePolicy(PricePolicy newPricePolicy, Long requestSellerId)

this.pricePolicy = newPricePolicy;
}

public void setId(Long id) {
this.id = id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,10 @@ public Auction save(Auction auction) {
if (auction.getId() == null || auction.getId() == 0L) {
// 새로운 Auction 객체인 경우
Long newId = id++;
Auction newAuction = Auction.builder()
.id(newId)
.startedAt(auction.getStartedAt())
.sellerId(auction.getSellerId())
.productName(auction.getProductName())
.originPrice(auction.getOriginPrice())
.stock(auction.getStock())
.maximumPurchaseLimitCount(auction.getMaximumPurchaseLimitCount())
.pricePolicy(auction.getPricePolicy())
.variationDuration(auction.getVariationDuration())
.finishedAt(auction.getFinishedAt())
.isShowStock(auction.isShowStock())
.auctionStatus(auction.getStatus())
.build();
auctions.put(newId, newAuction);
return newAuction;

auction.setId(newId);
auctions.put(newId, auction);
return auction;
} else {
// 기존 Auction 객체를 업데이트하는 경우
auctions.put(auction.getId(), auction);
Expand Down

0 comments on commit af11240

Please sign in to comment.