From e92f76e6b0c30d8683745d15bbf103475b593279 Mon Sep 17 00:00:00 2001 From: Ogu1208 Date: Fri, 12 Jul 2024 01:31:58 +0900 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=EC=B9=B4=ED=85=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=EB=B3=84=20=ED=8E=98=EC=9D=B4=EC=A7=95=20-=20?= =?UTF-8?q?=ED=82=A4=EC=9B=8C=EB=93=9C=20=EA=B2=80=EC=83=89,=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=A0=9C=EA=B1=B0(-1?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProductLineRepositoryCustomImpl.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/store/clothstar/productLine/repository/ProductLineRepositoryCustomImpl.java b/src/main/java/org/store/clothstar/productLine/repository/ProductLineRepositoryCustomImpl.java index 2df63e0..3888284 100644 --- a/src/main/java/org/store/clothstar/productLine/repository/ProductLineRepositoryCustomImpl.java +++ b/src/main/java/org/store/clothstar/productLine/repository/ProductLineRepositoryCustomImpl.java @@ -8,7 +8,8 @@ import org.springframework.data.domain.*; import org.springframework.data.support.PageableExecutionUtils; import org.springframework.stereotype.Repository; -import org.store.clothstar.member.entity.QSellerEntity; +import org.store.clothstar.member.domain.QMember; +import org.store.clothstar.member.domain.QSeller; import org.store.clothstar.product.dto.response.ProductResponse; import org.store.clothstar.product.entity.QProductEntity; import org.store.clothstar.productLine.dto.response.ProductLineWithProductsJPAResponse; @@ -16,7 +17,10 @@ import org.store.clothstar.productLine.entity.ProductLineEntity; import org.store.clothstar.productLine.entity.QProductLineEntity; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; import java.util.stream.Collectors; @Repository @@ -27,8 +31,8 @@ public class ProductLineRepositoryCustomImpl implements ProductLineRepositoryCus QProductLineEntity qProductLine = QProductLineEntity.productLineEntity; QProductEntity qProduct = QProductEntity.productEntity; - QSellerEntity qSeller = QSellerEntity.sellerEntity; - QMemberEntity qMember = QMemberEntity.memberEntity; + QSeller qSeller = QSeller.seller; + QMember qMember = QMember.member; @Override public Page getProductLinesWithOptions(Pageable pageable) { @@ -103,6 +107,12 @@ public Slice findAllSlicePaging(Pageable pag public Page findEntitiesByCategoryWithOffsetPaging(Long categoryId, Pageable pageable, String keyword) { List content = getProductLineEntitiesByCategory(categoryId, pageable, keyword); + boolean hasNext = false; + if (content.size() > pageable.getPageSize()) { + content.remove(content.size() - 1); + hasNext = true; + } + JPAQuery totalCount = jpaQueryFactory .select(qProductLine.countDistinct()) .from(qProductLine) @@ -177,7 +187,8 @@ private List getProductLineEntitiesByCategory(Long categoryId .selectDistinct(qProductLine) .from(qProductLine) .where(qProductLine.category.categoryId.eq(categoryId) - .and(qProductLine.deletedAt.isNull())) + .and(qProductLine.deletedAt.isNull()) + .and(getSearchCondition(keyword))) .orderBy(orderSpecifiers.toArray(new OrderSpecifier[0])) .offset(pageable.getOffset()) .limit(pageable.getPageSize() + 1) From bd896107112e4cce8ee87f68cce321b47ab08619 Mon Sep 17 00:00:00 2001 From: Ogu1208 Date: Fri, 12 Jul 2024 17:28:07 +0900 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20=EC=9E=98=EB=AA=BB=EB=90=9C=20P?= =?UTF-8?q?ageable=20import=20=EC=82=AD=EC=A0=9C,=20Order=20DTO=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/dto/reponse/QOrderResponse.java | 21 ------------------- .../orderDetail/dto/QOrderDetailDTO.java | 21 ------------------- .../controller/ProductLineController.java | 1 - 3 files changed, 43 deletions(-) delete mode 100644 src/main/generated/org/store/clothstar/order/dto/reponse/QOrderResponse.java delete mode 100644 src/main/generated/org/store/clothstar/orderDetail/dto/QOrderDetailDTO.java diff --git a/src/main/generated/org/store/clothstar/order/dto/reponse/QOrderResponse.java b/src/main/generated/org/store/clothstar/order/dto/reponse/QOrderResponse.java deleted file mode 100644 index a41b13b..0000000 --- a/src/main/generated/org/store/clothstar/order/dto/reponse/QOrderResponse.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.store.clothstar.order.dto.reponse; - -import com.querydsl.core.types.dsl.*; - -import com.querydsl.core.types.ConstructorExpression; -import javax.annotation.processing.Generated; - -/** - * org.store.clothstar.order.dto.reponse.QOrderResponse is a Querydsl Projection type for OrderResponse - */ -@Generated("com.querydsl.codegen.DefaultProjectionSerializer") -public class QOrderResponse extends ConstructorExpression { - - private static final long serialVersionUID = -1258133913L; - - public QOrderResponse(com.querydsl.core.types.Expression orderEntity, com.querydsl.core.types.Expression orderDetailEntity, com.querydsl.core.types.Expression memberEntity, com.querydsl.core.types.Expression addressEntity, com.querydsl.core.types.Expression productLineEntity) { - super(OrderResponse.class, new Class[]{org.store.clothstar.order.entity.OrderEntity.class, org.store.clothstar.orderDetail.entity.OrderDetailEntity.class, org.store.clothstar.member.entity.MemberEntity.class, org.store.clothstar.member.entity.AddressEntity.class, org.store.clothstar.productLine.entity.ProductLineEntity.class}, orderEntity, orderDetailEntity, memberEntity, addressEntity, productLineEntity); - } - -} - diff --git a/src/main/generated/org/store/clothstar/orderDetail/dto/QOrderDetailDTO.java b/src/main/generated/org/store/clothstar/orderDetail/dto/QOrderDetailDTO.java deleted file mode 100644 index bc407ad..0000000 --- a/src/main/generated/org/store/clothstar/orderDetail/dto/QOrderDetailDTO.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.store.clothstar.orderDetail.dto; - -import com.querydsl.core.types.dsl.*; - -import com.querydsl.core.types.ConstructorExpression; -import javax.annotation.processing.Generated; - -/** - * org.store.clothstar.orderDetail.dto.QOrderDetailDTO is a Querydsl Projection type for OrderDetailDTO - */ -@Generated("com.querydsl.codegen.DefaultProjectionSerializer") -public class QOrderDetailDTO extends ConstructorExpression { - - private static final long serialVersionUID = -767891785L; - - public QOrderDetailDTO(com.querydsl.core.types.Expression orderDetailEntity) { - super(OrderDetailDTO.class, new Class[]{org.store.clothstar.orderDetail.entity.OrderDetailEntity.class}, orderDetailEntity); - } - -} - diff --git a/src/main/java/org/store/clothstar/productLine/controller/ProductLineController.java b/src/main/java/org/store/clothstar/productLine/controller/ProductLineController.java index 4dab8b8..d0bef38 100644 --- a/src/main/java/org/store/clothstar/productLine/controller/ProductLineController.java +++ b/src/main/java/org/store/clothstar/productLine/controller/ProductLineController.java @@ -19,7 +19,6 @@ import org.store.clothstar.productLine.dto.response.ProductLineWithProductsJPAResponse; import org.store.clothstar.productLine.service.ProductLineService; -import java.awt.print.Pageable; import java.net.URI; import java.util.List; From 624ff15168e054bf461f37113bc88491e113d1c7 Mon Sep 17 00:00:00 2001 From: Ogu1208 Date: Fri, 12 Jul 2024 18:17:48 +0900 Subject: [PATCH 3/3] =?UTF-8?q?refactor:=20=ED=8E=98=EC=9D=B4=EC=A7=80?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EC=85=98=20N+1=EC=9D=84=20=ED=95=B4=EA=B2=B0?= =?UTF-8?q?=ED=95=98=EA=B8=B0=20=EC=9C=84=ED=95=9C=20default=5Fbatch=5Ffet?= =?UTF-8?q?ch=5Fsize=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/ProductLineWithProductsJPAResponse.java | 2 +- .../repository/ProductLineRepositoryCustomImpl.java | 1 - src/main/resources/application-db.yml | 5 +++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/store/clothstar/productLine/dto/response/ProductLineWithProductsJPAResponse.java b/src/main/java/org/store/clothstar/productLine/dto/response/ProductLineWithProductsJPAResponse.java index 03eabfd..b28cfa3 100644 --- a/src/main/java/org/store/clothstar/productLine/dto/response/ProductLineWithProductsJPAResponse.java +++ b/src/main/java/org/store/clothstar/productLine/dto/response/ProductLineWithProductsJPAResponse.java @@ -63,7 +63,7 @@ public class ProductLineWithProductsJPAResponse { private LocalDateTime modifiedAt; @QueryProjection - public ProductLineWithProductsJPAResponse(ProductLineEntity productLine, SellerEntity seller, Long totalStock) { + public ProductLineWithProductsJPAResponse(ProductLineEntity productLine, Seller seller, Long totalStock) { this.productLineId = productLine.getProductLineId(); this.name = productLine.getName(); this.content = productLine.getContent(); diff --git a/src/main/java/org/store/clothstar/productLine/repository/ProductLineRepositoryCustomImpl.java b/src/main/java/org/store/clothstar/productLine/repository/ProductLineRepositoryCustomImpl.java index 3888284..f9fc63c 100644 --- a/src/main/java/org/store/clothstar/productLine/repository/ProductLineRepositoryCustomImpl.java +++ b/src/main/java/org/store/clothstar/productLine/repository/ProductLineRepositoryCustomImpl.java @@ -32,7 +32,6 @@ public class ProductLineRepositoryCustomImpl implements ProductLineRepositoryCus QProductLineEntity qProductLine = QProductLineEntity.productLineEntity; QProductEntity qProduct = QProductEntity.productEntity; QSeller qSeller = QSeller.seller; - QMember qMember = QMember.member; @Override public Page getProductLinesWithOptions(Pageable pageable) { diff --git a/src/main/resources/application-db.yml b/src/main/resources/application-db.yml index 9136dd2..260a6bf 100644 --- a/src/main/resources/application-db.yml +++ b/src/main/resources/application-db.yml @@ -27,8 +27,9 @@ jwt: spring: jpa: - hibernate: - default_batch_fetch_size: 100 + properties: + hibernate: + default_batch_fetch_size: 1000 --- # local 공통 설정 spring: