Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

입찰 시 입찰하고자 하는 내용이 유효한지 검증하는 로직 변경 #745

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,8 @@ public Optional<User> findLastBidder() {

return Optional.of(lastBid.getBidder());
}

public Optional<Bid> findLastBid() {
return Optional.ofNullable(lastBid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,18 @@ private void checkInvalidAuction(final Auction auction) {
}

private void checkInvalidBid(final Auction auction, final User bidder, final CreateBidDto bidDto) {
final Optional<Bid> lastBid = bidRepository.findLastBidByAuctionId(bidDto.auctionId());
final BidPrice bidPrice = processBidPrice(bidDto.bidPrice());

checkIsSeller(auction, bidder);

if (lastBid.isPresent()) {
checkIsNotLastBidder(lastBid.get(), bidder);
checkInvalidBidPrice(lastBid.get(), bidPrice);
return;
}
final BidPrice bidPrice = processBidPrice(bidDto.bidPrice());

checkInvalidFirstBidPrice(auction, bidPrice);
auction.findLastBid()
.ifPresentOrElse(
lastBid -> {
checkIsNotLastBidder(lastBid, bidder);
checkInvalidBidPrice(lastBid, bidPrice);
},
() -> checkInvalidFirstBidPrice(auction, bidPrice)
);
}

private BidPrice processBidPrice(final int value) {
Expand Down
Loading