Skip to content

Commit

Permalink
Merge pull request #93 from ClothingStoreService/refactor/productLine…
Browse files Browse the repository at this point in the history
…-cactegory-pagination

Refactor/product line cactegory pagination
  • Loading branch information
Ogu1208 authored Jul 12, 2024
2 parents 54da983 + 624ff15 commit 7c02a0a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 51 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@
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;
import org.store.clothstar.productLine.dto.response.QProductLineWithProductsJPAResponse;
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
Expand All @@ -27,8 +31,7 @@ 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;

@Override
public Page<ProductLineWithProductsJPAResponse> getProductLinesWithOptions(Pageable pageable) {
Expand Down Expand Up @@ -103,6 +106,12 @@ public Slice<ProductLineWithProductsJPAResponse> findAllSlicePaging(Pageable pag
public Page<ProductLineEntity> findEntitiesByCategoryWithOffsetPaging(Long categoryId, Pageable pageable, String keyword) {
List<ProductLineEntity> content = getProductLineEntitiesByCategory(categoryId, pageable, keyword);

boolean hasNext = false;
if (content.size() > pageable.getPageSize()) {
content.remove(content.size() - 1);
hasNext = true;
}

JPAQuery<Long> totalCount = jpaQueryFactory
.select(qProductLine.countDistinct())
.from(qProductLine)
Expand Down Expand Up @@ -177,7 +186,8 @@ private List<ProductLineEntity> 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)
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/application-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ jwt:

spring:
jpa:
hibernate:
default_batch_fetch_size: 100
properties:
hibernate:
default_batch_fetch_size: 1000

--- # local 공통 설정
spring:
Expand Down

0 comments on commit 7c02a0a

Please sign in to comment.