From 32b35aeb962075fa3cd0256eaa61f7de7906e708 Mon Sep 17 00:00:00 2001 From: SCY Date: Fri, 16 Aug 2024 13:11:06 +0900 Subject: [PATCH 01/10] =?UTF-8?q?refactor:=20=EB=A7=88=EA=B0=90=EC=9E=84?= =?UTF-8?q?=EB=B0=95=EC=88=9C=20=ED=95=84=ED=84=B0=EB=A7=81=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EB=A7=88=EA=B0=90=EC=9E=84=EB=B0=95=EB=A7=8C?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: fromitive --- .../java/com/zzang/chongdae/offering/domain/OfferingFilter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/com/zzang/chongdae/offering/domain/OfferingFilter.java b/backend/src/main/java/com/zzang/chongdae/offering/domain/OfferingFilter.java index adfec224..e2c1eb27 100644 --- a/backend/src/main/java/com/zzang/chongdae/offering/domain/OfferingFilter.java +++ b/backend/src/main/java/com/zzang/chongdae/offering/domain/OfferingFilter.java @@ -14,7 +14,7 @@ public enum OfferingFilter { JOINABLE("참여가능만", VISIBLE), // 처음: 참여 가능한 것 중 id가 가장 높은 값 10개 / 이후: 참여 가능한 것 중 마지막 id보다 낮은 것 x개 찾기 - IMMINENT("마감임박순", VISIBLE), // 처음: 현재 시간보다 큰 것 중 가장 작은 값 10개 / 이후: lastMeetingDate 보다 큰 것 x개 찾기 + IMMINENT("마감임박만", VISIBLE), // 처음: 현재 시간보다 큰 것 중 가장 작은 값 10개 / 이후: lastMeetingDate 보다 큰 것 x개 찾기 HIGH_DISCOUNT("높은할인율순", VISIBLE), // 처음: 할인율(n빵가격/낱개가격) 가장 높은 값 10개 / 이후: 마지막 할인율(n빵가격/낱개가격)보다 낮은 것 x개 찾기 RECENT("최신순", INVISIBLE); // 처음: id가 가장 높은 값 10개 / 이후: 마지막 id보다 낮은 것 x개 찾기 From 2e17e7f9caa86359669b456543b9bdc7ded020f4 Mon Sep 17 00:00:00 2001 From: SCY Date: Fri, 16 Aug 2024 13:54:14 +0900 Subject: [PATCH 02/10] =?UTF-8?q?refactor:=20=ED=95=84=ED=84=B0=EB=A7=81?= =?UTF-8?q?=20=EC=BF=BC=EB=A6=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: fromitive --- .../HighDiscountOfferingStrategy.java | 6 ++-- .../repository/OfferingRepository.java | 29 ++++++++----------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/backend/src/main/java/com/zzang/chongdae/offering/domain/offeringfetchstrategy/HighDiscountOfferingStrategy.java b/backend/src/main/java/com/zzang/chongdae/offering/domain/offeringfetchstrategy/HighDiscountOfferingStrategy.java index 9e42115c..d6e851b3 100644 --- a/backend/src/main/java/com/zzang/chongdae/offering/domain/offeringfetchstrategy/HighDiscountOfferingStrategy.java +++ b/backend/src/main/java/com/zzang/chongdae/offering/domain/offeringfetchstrategy/HighDiscountOfferingStrategy.java @@ -22,8 +22,8 @@ protected List fetchOfferingsWithoutLastId(String searchKeyword, @Override protected List fetchOfferingsWithLastOffering( OfferingEntity lastOffering, String searchKeyword, Pageable pageable) { - double discountRate = lastOffering.toOfferingPrice().calculateDiscountRate(); - return offeringRepository.findHighDiscountOfferingsWithKeyword(discountRate, lastOffering.getId(), - searchKeyword, pageable); + double lastDiscountRate = lastOffering.toOfferingPrice().calculateDiscountRate(); + return offeringRepository.findHighDiscountOfferingsWithKeyword( + lastDiscountRate, lastOffering.getId(), searchKeyword, pageable); } } diff --git a/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java b/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java index 1cf21083..b6654395 100644 --- a/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java +++ b/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java @@ -11,10 +11,10 @@ public interface OfferingRepository extends JpaRepository { @Query(""" - SELECT o - FROM OfferingEntity as o JOIN OfferingMemberEntity as om - ON o.id = om.offering.id - WHERE om.member = :member + SELECT o + FROM OfferingEntity as o JOIN OfferingMemberEntity as om + ON o.id = om.offering.id + WHERE om.member = :member """) List findCommentRoomsByMember(MemberEntity member); @@ -30,14 +30,9 @@ public interface OfferingRepository extends JpaRepository @Query(""" SELECT o FROM OfferingEntity o - WHERE ((o.meetingDate > :lastMeetingDate AND o.meetingDate < :threshold) - OR (o.meetingDate = :lastMeetingDate AND o.id < :lastId AND o.meetingDate < :threshold) - OR (o.totalCount <= 3 AND (o.totalCount - o.currentCount) < 2 AND (o.totalCount - o.currentCount) > 0) - OR (o.totalCount > 3 AND (o.totalCount - o.currentCount) < 3 AND (o.totalCount - o.currentCount) > 0)) - AND (:keyword IS NULL OR o.title LIKE %:keyword% OR o.meetingAddress LIKE %:keyword%) - AND (o.isManualConfirmed IS FALSE) - AND (o.meetingDate >= :now) - AND ((o.meetingDate > :lastMeetingDate) OR (o.meetingDate = :lastMeetingDate AND o.id < :lastId)) + WHERE o.offeringStatus = 'IMMINENT' + AND ((o.meetingDate > :lastMeetingDate) OR (o.meetingDate = :lastMeetingDate AND o.id < :lastId)) + AND (:keyword IS NULL OR o.title LIKE %:keyword% OR o.meetingAddress LIKE %:keyword%) ORDER BY o.meetingDate ASC, o.id DESC """) List findImminentOfferingsWithKeyword( @@ -47,14 +42,14 @@ List findImminentOfferingsWithKeyword( @Query(""" SELECT o FROM OfferingEntity o - WHERE ((o.originPrice - (o.totalPrice * 1.0 / o.totalCount)) / o.originPrice < :discountRate - OR ((o.originPrice - (o.totalPrice * 1.0 / o.totalCount)) / o.originPrice = :discountRate AND o.id < :lastId)) + WHERE o.offeringStatus != 'CONFIRMED' + AND ((o.discountRate < :lastDiscountRate) OR (o.discountRate = :lastDiscountRate AND o.id < :lastId)) AND (:keyword IS NULL OR o.title LIKE %:keyword% OR o.meetingAddress LIKE %:keyword%) - ORDER BY (o.originPrice - (o.totalPrice * 1.0 / o.totalCount)) / o.originPrice DESC, o.id DESC + ORDER BY o.discountRate DESC, o.id DESC """) List findHighDiscountOfferingsWithKeyword( - double discountRate, Long lastId, String keyword, Pageable pageable); - + double lastDiscountRate, Long lastId, String keyword, Pageable pageable); + @Query("SELECT MAX(o.id) FROM OfferingEntity o") Long findMaxId(); } From 4dc29feae949348e9702e7a2bd38a8fbc6b3a860 Mon Sep 17 00:00:00 2001 From: SCY Date: Fri, 16 Aug 2024 14:05:16 +0900 Subject: [PATCH 03/10] =?UTF-8?q?feat:=20"=EC=B0=B8=EC=97=AC=EA=B0=80?= =?UTF-8?q?=EB=8A=A5=EB=A7=8C"=20=ED=95=84=ED=84=B0=EB=A7=81=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: fromitive --- .../repository/OfferingRepository.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java b/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java index b6654395..da67d695 100644 --- a/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java +++ b/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java @@ -30,8 +30,8 @@ public interface OfferingRepository extends JpaRepository @Query(""" SELECT o FROM OfferingEntity o - WHERE o.offeringStatus = 'IMMINENT' - AND ((o.meetingDate > :lastMeetingDate) OR (o.meetingDate = :lastMeetingDate AND o.id < :lastId)) + WHERE (o.offeringStatus = 'IMMINENT') + AND (o.meetingDate > :lastMeetingDate OR (o.meetingDate = :lastMeetingDate AND o.id < :lastId)) AND (:keyword IS NULL OR o.title LIKE %:keyword% OR o.meetingAddress LIKE %:keyword%) ORDER BY o.meetingDate ASC, o.id DESC """) @@ -42,14 +42,25 @@ List findImminentOfferingsWithKeyword( @Query(""" SELECT o FROM OfferingEntity o - WHERE o.offeringStatus != 'CONFIRMED' - AND ((o.discountRate < :lastDiscountRate) OR (o.discountRate = :lastDiscountRate AND o.id < :lastId)) + WHERE (o.offeringStatus != 'CONFIRMED') + AND (o.discountRate < :lastDiscountRate OR (o.discountRate = :lastDiscountRate AND o.id < :lastId)) AND (:keyword IS NULL OR o.title LIKE %:keyword% OR o.meetingAddress LIKE %:keyword%) ORDER BY o.discountRate DESC, o.id DESC """) List findHighDiscountOfferingsWithKeyword( double lastDiscountRate, Long lastId, String keyword, Pageable pageable); - + + @Query(""" + SELECT o + FROM OfferingEntity o + WHERE (o.offeringStatus = 'AVAILABLE' OR o.offeringStatus = 'IMMINENT') + AND (o.id < :lastId) + AND (:keyword IS NULL OR o.title LIKE %:keyword% OR o.meetingAddress LIKE %:keyword%) + ORDER BY o.id DESC + """) + List findJoinableOfferingsWithKeyword(Long lastId, String keyword, Pageable pageable); + + @Query("SELECT MAX(o.id) FROM OfferingEntity o") Long findMaxId(); } From 4a162e6961e921f127cdeb5a104d81c13feeae75 Mon Sep 17 00:00:00 2001 From: SCY Date: Fri, 16 Aug 2024 14:05:25 +0900 Subject: [PATCH 04/10] =?UTF-8?q?feat:=20"=EC=B0=B8=EC=97=AC=EA=B0=80?= =?UTF-8?q?=EB=8A=A5=EB=A7=8C"=20=ED=95=84=ED=84=B0=EB=A7=81=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: fromitive --- .../com/zzang/chongdae/offering/service/OfferingFetcher.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/src/main/java/com/zzang/chongdae/offering/service/OfferingFetcher.java b/backend/src/main/java/com/zzang/chongdae/offering/service/OfferingFetcher.java index 5877138d..62a6967a 100644 --- a/backend/src/main/java/com/zzang/chongdae/offering/service/OfferingFetcher.java +++ b/backend/src/main/java/com/zzang/chongdae/offering/service/OfferingFetcher.java @@ -4,6 +4,7 @@ import com.zzang.chongdae.offering.domain.OfferingFilter; import com.zzang.chongdae.offering.domain.offeringfetchstrategy.HighDiscountOfferingStrategy; import com.zzang.chongdae.offering.domain.offeringfetchstrategy.ImminentOfferingStrategy; +import com.zzang.chongdae.offering.domain.offeringfetchstrategy.JoinableOfferingStrategy; import com.zzang.chongdae.offering.domain.offeringfetchstrategy.OfferingFetchStrategy; import com.zzang.chongdae.offering.domain.offeringfetchstrategy.RecentOfferingStrategy; import com.zzang.chongdae.offering.exception.OfferingErrorCode; @@ -27,7 +28,8 @@ public OfferingFetcher(OfferingRepository offeringRepository) { this.strategyMap = Map.of( OfferingFilter.RECENT, new RecentOfferingStrategy(offeringRepository), OfferingFilter.IMMINENT, new ImminentOfferingStrategy(offeringRepository), - OfferingFilter.HIGH_DISCOUNT, new HighDiscountOfferingStrategy(offeringRepository) + OfferingFilter.HIGH_DISCOUNT, new HighDiscountOfferingStrategy(offeringRepository), + OfferingFilter.JOINABLE, new JoinableOfferingStrategy(offeringRepository) ); } From e54e648eef9d0c3b69c6962d1d93a0129c05ea99 Mon Sep 17 00:00:00 2001 From: SCY Date: Fri, 16 Aug 2024 14:12:22 +0900 Subject: [PATCH 05/10] =?UTF-8?q?fix:=20=EC=BF=BC=EB=A6=AC=20=EB=82=B4=20?= =?UTF-8?q?=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20=ED=8C=8C=EB=9D=BC?= =?UTF-8?q?=EB=AF=B8=ED=84=B0=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: fromitive --- .../offeringfetchstrategy/ImminentOfferingStrategy.java | 8 ++------ .../chongdae/offering/repository/OfferingRepository.java | 3 +-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/com/zzang/chongdae/offering/domain/offeringfetchstrategy/ImminentOfferingStrategy.java b/backend/src/main/java/com/zzang/chongdae/offering/domain/offeringfetchstrategy/ImminentOfferingStrategy.java index 35d82dc4..5966f6c5 100644 --- a/backend/src/main/java/com/zzang/chongdae/offering/domain/offeringfetchstrategy/ImminentOfferingStrategy.java +++ b/backend/src/main/java/com/zzang/chongdae/offering/domain/offeringfetchstrategy/ImminentOfferingStrategy.java @@ -14,22 +14,18 @@ public ImminentOfferingStrategy(OfferingRepository offeringRepository) { @Override protected List fetchOfferingsWithoutLastId(String searchKeyword, Pageable pageable) { - LocalDateTime now = LocalDateTime.now(); - LocalDateTime threshold = LocalDateTime.now().plusHours(6); LocalDateTime outOfRangeMeetingDate = LocalDateTime.now(); Long outOfRangeId = findOutOfRangeId(); return offeringRepository.findImminentOfferingsWithKeyword( - now, threshold, outOfRangeMeetingDate, outOfRangeId, searchKeyword, pageable); + outOfRangeMeetingDate, outOfRangeId, searchKeyword, pageable); } @Override protected List fetchOfferingsWithLastOffering( OfferingEntity lastOffering, String searchKeyword, Pageable pageable) { - LocalDateTime now = LocalDateTime.now(); - LocalDateTime threshold = LocalDateTime.now().plusHours(6); LocalDateTime lastMeetingDate = lastOffering.getMeetingDate(); Long lastId = lastOffering.getId(); return offeringRepository.findImminentOfferingsWithKeyword( - now, threshold, lastMeetingDate, lastId, searchKeyword, pageable); + lastMeetingDate, lastId, searchKeyword, pageable); } } diff --git a/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java b/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java index da67d695..0fb66007 100644 --- a/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java +++ b/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java @@ -36,8 +36,7 @@ public interface OfferingRepository extends JpaRepository ORDER BY o.meetingDate ASC, o.id DESC """) List findImminentOfferingsWithKeyword( - LocalDateTime now, LocalDateTime threshold, LocalDateTime lastMeetingDate, Long lastId, String keyword, - Pageable pageable); + LocalDateTime lastMeetingDate, Long lastId, String keyword, Pageable pageable); @Query(""" SELECT o From 574c21bcd89c3fd304b09f8bc295174228fdfaff Mon Sep 17 00:00:00 2001 From: SCY Date: Fri, 16 Aug 2024 14:41:38 +0900 Subject: [PATCH 06/10] =?UTF-8?q?refactor:=20=ED=95=A0=EC=9D=B8=EC=9C=A8?= =?UTF-8?q?=EC=9D=B4=20null=EC=9D=BC=20=EA=B2=BD=EC=9A=B0=20=EB=86=92?= =?UTF-8?q?=EC=9D=80=ED=95=A0=EC=9D=B8=EC=9C=A8=20=ED=95=84=ED=84=B0?= =?UTF-8?q?=EB=A7=81=20=EB=8C=80=EC=83=81=EC=97=90=EC=84=9C=20=EC=A0=9C?= =?UTF-8?q?=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: fromitive --- .../zzang/chongdae/offering/repository/OfferingRepository.java | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java b/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java index 0fb66007..60368caa 100644 --- a/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java +++ b/backend/src/main/java/com/zzang/chongdae/offering/repository/OfferingRepository.java @@ -42,6 +42,7 @@ List findImminentOfferingsWithKeyword( SELECT o FROM OfferingEntity o WHERE (o.offeringStatus != 'CONFIRMED') + AND (o.discountRate IS NOT NULL) AND (o.discountRate < :lastDiscountRate OR (o.discountRate = :lastDiscountRate AND o.id < :lastId)) AND (:keyword IS NULL OR o.title LIKE %:keyword% OR o.meetingAddress LIKE %:keyword%) ORDER BY o.discountRate DESC, o.id DESC From 25a1c28cba6ada335fb01b257bb57060ea88b2da Mon Sep 17 00:00:00 2001 From: SCY Date: Fri, 16 Aug 2024 16:26:37 +0900 Subject: [PATCH 07/10] =?UTF-8?q?feat:=20=EC=B0=B8=EC=97=AC=EA=B0=80?= =?UTF-8?q?=EB=8A=A5=EB=A7=8C=20=ED=95=84=ED=84=B0=EB=A7=81=20=EC=A0=84?= =?UTF-8?q?=EB=9E=B5=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../JoinableOfferingStrategy.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 backend/src/main/java/com/zzang/chongdae/offering/domain/offeringfetchstrategy/JoinableOfferingStrategy.java diff --git a/backend/src/main/java/com/zzang/chongdae/offering/domain/offeringfetchstrategy/JoinableOfferingStrategy.java b/backend/src/main/java/com/zzang/chongdae/offering/domain/offeringfetchstrategy/JoinableOfferingStrategy.java new file mode 100644 index 00000000..53f39210 --- /dev/null +++ b/backend/src/main/java/com/zzang/chongdae/offering/domain/offeringfetchstrategy/JoinableOfferingStrategy.java @@ -0,0 +1,25 @@ +package com.zzang.chongdae.offering.domain.offeringfetchstrategy; + +import com.zzang.chongdae.offering.repository.OfferingRepository; +import com.zzang.chongdae.offering.repository.entity.OfferingEntity; +import java.util.List; +import org.springframework.data.domain.Pageable; + +public class JoinableOfferingStrategy extends OfferingFetchStrategy { + + public JoinableOfferingStrategy(OfferingRepository offeringRepository) { + super(offeringRepository); + } + + @Override + protected List fetchOfferingsWithoutLastId(String searchKeyword, Pageable pageable) { + Long outOfRangeId = findOutOfRangeId(); + return offeringRepository.findJoinableOfferingsWithKeyword(outOfRangeId, searchKeyword, pageable); + } + + @Override + protected List fetchOfferingsWithLastOffering(OfferingEntity lastOffering, String searchKeyword, + Pageable pageable) { + return offeringRepository.findJoinableOfferingsWithKeyword(lastOffering.getId(), searchKeyword, pageable); + } +} From 9ad442470266cd1d83e63cd75c78e0cdc55e8bc4 Mon Sep 17 00:00:00 2001 From: fromitive Date: Fri, 16 Aug 2024 16:41:52 +0900 Subject: [PATCH 08/10] =?UTF-8?q?feat:=20=EA=B3=B5=EB=AA=A8=20=EB=AA=A9?= =?UTF-8?q?=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20API=20=EC=9D=91=EB=8B=B5?= =?UTF-8?q?=EA=B0=92=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chongdae/offering/service/OfferingService.java | 5 ++--- .../service/dto/OfferingAllResponseItem.java | 13 +++++++------ .../integration/OfferingIntegrationTest.java | 1 + 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/backend/src/main/java/com/zzang/chongdae/offering/service/OfferingService.java b/backend/src/main/java/com/zzang/chongdae/offering/service/OfferingService.java index 12c5003a..a2108d07 100644 --- a/backend/src/main/java/com/zzang/chongdae/offering/service/OfferingService.java +++ b/backend/src/main/java/com/zzang/chongdae/offering/service/OfferingService.java @@ -2,10 +2,10 @@ import com.zzang.chongdae.global.exception.MarketException; import com.zzang.chongdae.member.repository.entity.MemberEntity; +import com.zzang.chongdae.offering.domain.OfferingCondition; import com.zzang.chongdae.offering.domain.OfferingFilter; import com.zzang.chongdae.offering.domain.OfferingMeeting; import com.zzang.chongdae.offering.domain.OfferingPrice; -import com.zzang.chongdae.offering.domain.OfferingCondition; import com.zzang.chongdae.offering.exception.OfferingErrorCode; import com.zzang.chongdae.offering.repository.OfferingRepository; import com.zzang.chongdae.offering.repository.entity.OfferingEntity; @@ -59,8 +59,7 @@ public OfferingAllResponse getAllOffering(String filterName, String searchKeywor return new OfferingAllResponse(offerings.stream() .map(offering -> { OfferingPrice offeringPrice = offering.toOfferingPrice(); - OfferingCondition offeringCondition = offering.toOfferingCondition(); - return new OfferingAllResponseItem(offering, offeringPrice, offeringCondition); + return new OfferingAllResponseItem(offering, offeringPrice); }) .toList() ); diff --git a/backend/src/main/java/com/zzang/chongdae/offering/service/dto/OfferingAllResponseItem.java b/backend/src/main/java/com/zzang/chongdae/offering/service/dto/OfferingAllResponseItem.java index e321197e..1bdaddc7 100644 --- a/backend/src/main/java/com/zzang/chongdae/offering/service/dto/OfferingAllResponseItem.java +++ b/backend/src/main/java/com/zzang/chongdae/offering/service/dto/OfferingAllResponseItem.java @@ -1,8 +1,7 @@ package com.zzang.chongdae.offering.service.dto; -import com.zzang.chongdae.offering.domain.OfferingStatus; import com.zzang.chongdae.offering.domain.OfferingPrice; -import com.zzang.chongdae.offering.domain.OfferingCondition; +import com.zzang.chongdae.offering.domain.OfferingStatus; import com.zzang.chongdae.offering.repository.entity.OfferingEntity; public record OfferingAllResponseItem(Long id, @@ -13,21 +12,23 @@ public record OfferingAllResponseItem(Long id, String thumbnailUrl, Integer dividedPrice, Integer originPrice, + Double discountRate, OfferingStatus status, Boolean isOpen) { public OfferingAllResponseItem( - OfferingEntity offering, OfferingPrice offeringPrice, OfferingCondition offeringCondition) { + OfferingEntity offering, OfferingPrice offeringPrice) { this(offering.getId(), offering.getTitle(), offering.getMeetingAddressDong(), - offeringCondition.getCurrentCount(), + offering.getCurrentCount(), offering.getTotalCount(), offering.getThumbnailUrl(), offeringPrice.calculateDividedPrice(), offeringPrice.getOriginPrice(), - offeringCondition.decideOfferingStatus(), - offeringCondition.isOpen() + offering.getDiscountRate(), + offering.getOfferingStatus(), + offering.getOfferingStatus().isOpen() ); } } diff --git a/backend/src/test/java/com/zzang/chongdae/offering/integration/OfferingIntegrationTest.java b/backend/src/test/java/com/zzang/chongdae/offering/integration/OfferingIntegrationTest.java index 87914742..f5805d4d 100644 --- a/backend/src/test/java/com/zzang/chongdae/offering/integration/OfferingIntegrationTest.java +++ b/backend/src/test/java/com/zzang/chongdae/offering/integration/OfferingIntegrationTest.java @@ -134,6 +134,7 @@ class GetAllOffering { fieldWithPath("offerings[].thumbnailUrl").description("사진 링크"), fieldWithPath("offerings[].dividedPrice").description("n빵 가격"), fieldWithPath("offerings[].originPrice").description("원 가격"), + fieldWithPath("offerings[].discountRate").description("할인율"), fieldWithPath("offerings[].status").description("공모 상태" + getEnumValuesAsString(OfferingStatus.class)), fieldWithPath("offerings[].isOpen").description("공모 참여 가능 여부") From 4076a364da94b3f1dd24d618f8dc0e1535f95517 Mon Sep 17 00:00:00 2001 From: fromitive Date: Fri, 16 Aug 2024 16:50:29 +0900 Subject: [PATCH 09/10] =?UTF-8?q?fix:=20=EB=86=92=EC=9D=80=20=ED=95=A0?= =?UTF-8?q?=EC=9D=B8=EC=9C=A8=20=EB=8B=A8=EC=9C=84=20=EB=B3=80=EA=B2=BD=20?= =?UTF-8?q?=EB=B0=8F=20last-id=20=ED=95=84=ED=84=B0=EB=A7=81=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../offeringfetchstrategy/HighDiscountOfferingStrategy.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/com/zzang/chongdae/offering/domain/offeringfetchstrategy/HighDiscountOfferingStrategy.java b/backend/src/main/java/com/zzang/chongdae/offering/domain/offeringfetchstrategy/HighDiscountOfferingStrategy.java index d6e851b3..5bf46027 100644 --- a/backend/src/main/java/com/zzang/chongdae/offering/domain/offeringfetchstrategy/HighDiscountOfferingStrategy.java +++ b/backend/src/main/java/com/zzang/chongdae/offering/domain/offeringfetchstrategy/HighDiscountOfferingStrategy.java @@ -13,7 +13,7 @@ public HighDiscountOfferingStrategy(OfferingRepository offeringRepository) { @Override protected List fetchOfferingsWithoutLastId(String searchKeyword, Pageable pageable) { - double outOfRangeDiscountRate = 1; + double outOfRangeDiscountRate = 100; Long outOfRangeId = findOutOfRangeId(); return offeringRepository.findHighDiscountOfferingsWithKeyword( outOfRangeDiscountRate, outOfRangeId, searchKeyword, pageable); @@ -22,7 +22,7 @@ protected List fetchOfferingsWithoutLastId(String searchKeyword, @Override protected List fetchOfferingsWithLastOffering( OfferingEntity lastOffering, String searchKeyword, Pageable pageable) { - double lastDiscountRate = lastOffering.toOfferingPrice().calculateDiscountRate(); + double lastDiscountRate = lastOffering.getDiscountRate(); return offeringRepository.findHighDiscountOfferingsWithKeyword( lastDiscountRate, lastOffering.getId(), searchKeyword, pageable); } From 265a83960bea2c6da699c46f8d7943880a0a116c Mon Sep 17 00:00:00 2001 From: fromitive Date: Fri, 16 Aug 2024 16:50:40 +0900 Subject: [PATCH 10/10] =?UTF-8?q?style:=20=EC=A3=BC=EC=84=9D=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zzang/chongdae/offering/domain/OfferingFilter.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/src/main/java/com/zzang/chongdae/offering/domain/OfferingFilter.java b/backend/src/main/java/com/zzang/chongdae/offering/domain/OfferingFilter.java index e2c1eb27..03cc9561 100644 --- a/backend/src/main/java/com/zzang/chongdae/offering/domain/OfferingFilter.java +++ b/backend/src/main/java/com/zzang/chongdae/offering/domain/OfferingFilter.java @@ -13,10 +13,10 @@ @AllArgsConstructor public enum OfferingFilter { - JOINABLE("참여가능만", VISIBLE), // 처음: 참여 가능한 것 중 id가 가장 높은 값 10개 / 이후: 참여 가능한 것 중 마지막 id보다 낮은 것 x개 찾기 - IMMINENT("마감임박만", VISIBLE), // 처음: 현재 시간보다 큰 것 중 가장 작은 값 10개 / 이후: lastMeetingDate 보다 큰 것 x개 찾기 - HIGH_DISCOUNT("높은할인율순", VISIBLE), // 처음: 할인율(n빵가격/낱개가격) 가장 높은 값 10개 / 이후: 마지막 할인율(n빵가격/낱개가격)보다 낮은 것 x개 찾기 - RECENT("최신순", INVISIBLE); // 처음: id가 가장 높은 값 10개 / 이후: 마지막 id보다 낮은 것 x개 찾기 + JOINABLE("참여가능만", VISIBLE), + IMMINENT("마감임박만", VISIBLE), + HIGH_DISCOUNT("높은할인율순", VISIBLE), + RECENT("최신순", INVISIBLE); private final String value; private final OfferingFilterType type;