diff --git a/src/main/java/com/example/repick/domain/product/repository/ProductRepositoryCustom.java b/src/main/java/com/example/repick/domain/product/repository/ProductRepositoryCustom.java index 2c4183b..3d90695 100644 --- a/src/main/java/com/example/repick/domain/product/repository/ProductRepositoryCustom.java +++ b/src/main/java/com/example/repick/domain/product/repository/ProductRepositoryCustom.java @@ -44,8 +44,6 @@ Page findHighestDiscountProducts( List findProductDtoByClothingSalesId(long clothingSalesId); - List findByProductSellingStateType(ProductStateType productStateType); - List getBrandList(); List findRecommendation(Long userId); diff --git a/src/main/java/com/example/repick/domain/product/repository/ProductRepositoryImpl.java b/src/main/java/com/example/repick/domain/product/repository/ProductRepositoryImpl.java index 3275079..241c43b 100644 --- a/src/main/java/com/example/repick/domain/product/repository/ProductRepositoryImpl.java +++ b/src/main/java/com/example/repick/domain/product/repository/ProductRepositoryImpl.java @@ -12,7 +12,6 @@ import com.querydsl.core.types.Projections; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.core.types.dsl.CaseBuilder; -import com.querydsl.core.types.dsl.Expressions; import com.querydsl.core.types.dsl.StringExpression; import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.impl.JPAQuery; @@ -69,8 +68,6 @@ private Page findProducts( .on(product.id.eq(productCategory.product.id)) .leftJoin(productMaterial) .on(product.id.eq(productMaterial.product.id)) - .leftJoin(productState) - .on(product.id.eq(productState.productId)) .where( keywordFilter(productFilter.keyword()), genderFilter(productFilter.gender()), @@ -82,7 +79,7 @@ private Page findProducts( sizesFilter(productFilter.sizes()), materialsFilter(productFilter.materials()), deletedFilter(), - sellingStateFilter(ProductStateType.SELLING)) + sellingStateFilter()) .distinct() .orderBy(orderBy); @@ -138,7 +135,8 @@ public Page findLikedProducts(String category, Long userId, .where( likeFilter(userId), categoryFilter(category, false), - deletedFilter()) + deletedFilter(), + sellingStateFilter()) .distinct() .orderBy(productLike.id.desc()); long total = query.stream().count(); @@ -257,24 +255,8 @@ private BooleanExpression deletedFilter() { return product.isDeleted.eq(false); } - private BooleanExpression sellingStateFilter(ProductStateType productStateType) { - if (productStateType == null) { - return null; - } - - QProductState subProductState = new QProductState("subProductState"); - - return productState.id.in( - JPAExpressions - .select(subProductState.id) - .from(subProductState) - .where(subProductState.id.in( - JPAExpressions - .select(productState.id.max()) - .from(productState) - .groupBy(productState.productId) - ).and(subProductState.productStateType.eq(ProductStateType.SELLING))) - ); + private BooleanExpression sellingStateFilter() { + return product.productState.eq(ProductStateType.SELLING); } private BooleanExpression stylesFilter(List styles) { @@ -311,13 +293,11 @@ public Page findMainPageRecommendation(Pageable pageable, L .on(product.id.eq(productStyle.product.id)) .leftJoin(productCategory) .on(product.id.eq(productCategory.product.id)) - .leftJoin(productState) - .on(product.id.eq(productState.productId)) .where( genderFilter(gender), subCategoryFilter(subCategories), deletedFilter(), - sellingStateFilter(ProductStateType.SELLING)) + sellingStateFilter()) .distinct() .orderBy(product.id.desc()); long total = query.stream().count(); @@ -348,16 +328,6 @@ public List findProductDtoByClothingSalesId(long c .fetch(); } - @Override - public List findByProductSellingStateType(ProductStateType productStateType) { - return jpaQueryFactory - .selectFrom(product) - .leftJoin(productState) - .on(product.id.eq(productState.productId)) - .where(sellingStateFilter(productStateType)) - .fetch(); - } - @Override public List getBrandList() { return jpaQueryFactory