From e3d0f0aecae73e8aef0a6fc7b18d081cfc69ae0c Mon Sep 17 00:00:00 2001 From: qwerty1434 Date: Tue, 16 Jan 2024 17:02:47 +0900 Subject: [PATCH 1/2] =?UTF-8?q?:pencil2:=20=EC=9C=A0=EC=A0=80=EC=9D=98=20?= =?UTF-8?q?=EC=BF=A0=ED=8F=B0=20=EC=A1=B0=ED=9A=8C=EC=8B=9C=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20Join=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EC=9D=B4=EC=83=81=ED=95=9C=20=EA=B0=92=EC=9D=B4=20=EB=B3=B4?= =?UTF-8?q?=EC=9D=B4=EB=8D=98=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/coupon/repository/CouponRepositoryCustomImpl.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustomImpl.java b/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustomImpl.java index 0905a1e..e60ee91 100644 --- a/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustomImpl.java +++ b/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustomImpl.java @@ -39,8 +39,6 @@ public List findAllDtoByStoreId(Long storeId, LocalDate now) coupon.endDate )) .from(coupon) - .leftJoin(issuedCoupon) - .on(coupon.id.eq(issuedCoupon.id.couponId)) .where( coupon.store.id.eq(storeId), coupon.isDeleted.isFalse(), From e17037cb59bc8a135ecb102ee49af43db6dae5dd Mon Sep 17 00:00:00 2001 From: qwerty1434 Date: Tue, 16 Jan 2024 17:24:28 +0900 Subject: [PATCH 2/2] =?UTF-8?q?:pencil2:=20=EC=BF=A0=ED=8F=B0=20=EC=9D=BC?= =?UTF-8?q?=EA=B4=84=20=EB=8B=A4=EC=9A=B4=EB=A1=9C=EB=93=9C=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 --- .../kr/bb/store/domain/coupon/handler/CouponReader.java | 2 +- .../domain/coupon/repository/CouponRepositoryCustom.java | 2 +- .../coupon/repository/CouponRepositoryCustomImpl.java | 5 +---- .../kr/bb/store/domain/coupon/handler/CouponReaderTest.java | 6 +++--- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/kr/bb/store/domain/coupon/handler/CouponReader.java b/src/main/java/kr/bb/store/domain/coupon/handler/CouponReader.java index 9be5fdb..ef78cb0 100644 --- a/src/main/java/kr/bb/store/domain/coupon/handler/CouponReader.java +++ b/src/main/java/kr/bb/store/domain/coupon/handler/CouponReader.java @@ -27,7 +27,7 @@ public List readCouponsForOwner(Long storeId, LocalDate now) } public List readStoresAllValidateCoupon(Long storeId, LocalDate now) { - return couponRepository.findAllDownloadableCouponsByStoreId(storeId, now); + return couponRepository.findAllValidateCouponsByStoreId(storeId, now); } public List readStoreCouponsForUser(Long userId, Long storeId, LocalDate now) { diff --git a/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustom.java b/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustom.java index 57affd4..0531075 100644 --- a/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustom.java +++ b/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustom.java @@ -11,7 +11,7 @@ public interface CouponRepositoryCustom { List findAllDtoByStoreId(Long storeId, LocalDate now); - List findAllDownloadableCouponsByStoreId(Long storeId, LocalDate now); + List findAllValidateCouponsByStoreId(Long storeId, LocalDate now); List findStoreCouponsForUser(Long userId, Long storeId, LocalDate now); List findAvailableCoupons(Long totalAmount, Long userId, Long storeId, LocalDate now); List findMyValidCoupons(Long userId, LocalDate now); diff --git a/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustomImpl.java b/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustomImpl.java index e60ee91..ced292a 100644 --- a/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustomImpl.java +++ b/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustomImpl.java @@ -48,14 +48,11 @@ public List findAllDtoByStoreId(Long storeId, LocalDate now) } @Override - public List findAllDownloadableCouponsByStoreId(Long storeId, LocalDate now) { + public List findAllValidateCouponsByStoreId(Long storeId, LocalDate now) { return queryFactory .selectFrom(coupon) - .leftJoin(issuedCoupon) - .on(issuedCoupon.coupon.id.eq(coupon.id)) .where( coupon.store.id.eq(storeId), - issuedCoupon.id.isNull(), isCouponUnexpired(now), coupon.isDeleted.isFalse() ) diff --git a/src/test/java/kr/bb/store/domain/coupon/handler/CouponReaderTest.java b/src/test/java/kr/bb/store/domain/coupon/handler/CouponReaderTest.java index dd58432..54adfe8 100644 --- a/src/test/java/kr/bb/store/domain/coupon/handler/CouponReaderTest.java +++ b/src/test/java/kr/bb/store/domain/coupon/handler/CouponReaderTest.java @@ -332,7 +332,7 @@ void readMyValidCouponCount() { assertThat(result).isEqualTo(1); } - @DisplayName("현재 다운받을 수 있는 쿠폰 목록을 반환한다") + @DisplayName("현재 가게의 유효한 쿠폰 목록을 반환한다") @Test void readStoresAllValidateCoupon() { // given @@ -359,8 +359,8 @@ void readStoresAllValidateCoupon() { List result = couponReader.readStoresAllValidateCoupon(s1.getId(), now.plusDays(3)); // then - assertThat(result).hasSize(1) - .containsExactly(c1); + assertThat(result).hasSize(3) + .containsExactly(c1,c2,c3); }