From 1a3024d1bdcece0a08ee09d8cbabccf9fa25d920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9E=84=EB=8F=99=ED=98=84?= Date: Tue, 19 Dec 2023 19:15:55 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=ED=98=91=EC=97=85=EC=A7=80=EC=A0=90?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EC=9A=B0=EC=82=B0=EC=9D=B4=20=EC=97=86?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=EB=8F=84=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=EB=90=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95=20(#424)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit umbrella를 기준으로 조회하던 쿼리를 storeMeta를 기준으로 조회해서, 우산이 없더라도 조회되도록 수정 --- .../repository/StoreMetaRepositoryImpl.java | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/main/java/upbrella/be/store/repository/StoreMetaRepositoryImpl.java b/src/main/java/upbrella/be/store/repository/StoreMetaRepositoryImpl.java index 0f80047d..2aca41ab 100644 --- a/src/main/java/upbrella/be/store/repository/StoreMetaRepositoryImpl.java +++ b/src/main/java/upbrella/be/store/repository/StoreMetaRepositoryImpl.java @@ -1,16 +1,15 @@ package upbrella.be.store.repository; +import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import upbrella.be.store.dto.response.QStoreMetaWithUmbrellaCount; import upbrella.be.store.dto.response.StoreMetaWithUmbrellaCount; +import upbrella.be.store.entity.QStoreMeta; +import upbrella.be.umbrella.entity.QUmbrella; import java.util.List; -import static upbrella.be.store.entity.QBusinessHour.businessHour; -import static upbrella.be.store.entity.QClassification.classification; -import static upbrella.be.store.entity.QStoreMeta.storeMeta; -import static upbrella.be.umbrella.entity.QUmbrella.umbrella; @RequiredArgsConstructor public class StoreMetaRepositoryImpl implements StoreMetaRepositoryCustom { @@ -20,24 +19,21 @@ public class StoreMetaRepositoryImpl implements StoreMetaRepositoryCustom { @Override public List findAllStoresByClassification(long classificationId) { - QStoreMetaWithUmbrellaCount storeMetaWithUmbrellaCount = new QStoreMetaWithUmbrellaCount( - storeMeta, - umbrella.id.countDistinct().as("rentableUmbrellasCount") - ); - + QStoreMeta storeMeta = QStoreMeta.storeMeta; + QUmbrella umbrella = QUmbrella.umbrella; return queryFactory - .select(storeMetaWithUmbrellaCount) - .from(umbrella) - .rightJoin(umbrella.storeMeta, storeMeta) - .leftJoin(storeMeta.classification, classification).fetchJoin() - .where(storeMeta.deleted.eq(false) - .and(storeMeta.classification.id.eq(classificationId)) - .and(umbrella.rentable.eq(true)) - .and(umbrella.missed.eq(false)) - .and(umbrella.deleted.eq(false))) - .distinct() - .groupBy(storeMeta) + .select(new QStoreMetaWithUmbrellaCount( + storeMeta, + JPAExpressions.select(umbrella.count()) + .from(umbrella) + .where(umbrella.storeMeta.id.eq(storeMeta.id), + umbrella.rentable.isTrue(), + umbrella.missed.isFalse(), + umbrella.deleted.isFalse()))) + .from(storeMeta) + .where(storeMeta.classification.id.eq(classificationId)) .fetch(); } + }