From 8b0526d70054c7177eeba7be01bafa7790d79979 Mon Sep 17 00:00:00 2001 From: kwonyj1022 Date: Wed, 22 Nov 2023 17:57:43 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EC=9E=85=EC=B0=B0=20=EC=8B=9C=20?= =?UTF-8?q?=EC=9E=85=EC=B0=B0=ED=95=98=EA=B3=A0=EC=9E=90=20=ED=95=98?= =?UTF-8?q?=EB=8A=94=20=EB=82=B4=EC=9A=A9=EC=9D=B4=20=EC=9C=A0=ED=9A=A8?= =?UTF-8?q?=ED=95=9C=EC=A7=80=20=EA=B2=80=EC=A6=9D=ED=95=98=EB=8A=94=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ddang/bid/application/BidService.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/backend/ddang/src/main/java/com/ddang/ddang/bid/application/BidService.java b/backend/ddang/src/main/java/com/ddang/ddang/bid/application/BidService.java index 287cbddad..7f42911f7 100644 --- a/backend/ddang/src/main/java/com/ddang/ddang/bid/application/BidService.java +++ b/backend/ddang/src/main/java/com/ddang/ddang/bid/application/BidService.java @@ -25,7 +25,6 @@ import java.time.LocalDateTime; import java.util.List; -import java.util.Optional; @Service @Transactional(readOnly = true) @@ -84,18 +83,18 @@ private void checkInvalidAuction(final Auction auction) { } private void checkInvalidBid(final Auction auction, final User bidder, final CreateBidDto bidDto) { - final Optional 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) {