Skip to content

Commit

Permalink
edit : 상품 중분류 별 조회 시 무한스크롤 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
bongsh0112 committed Dec 21, 2023
1 parent af2c15a commit eef0ff0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.springframework.web.bind.annotation.RestController;
import tify.server.api.common.slice.SliceResponse;
import tify.server.api.product.model.dto.ProductFilterCondition;
import tify.server.api.product.model.vo.ProductRetrieveVo;
import tify.server.api.product.service.CrawlingUseCase;
import tify.server.api.product.service.ProductSearchUseCase;
import tify.server.api.product.service.RetrieveProductListUseCase;
Expand Down Expand Up @@ -59,10 +60,11 @@ public SliceResponse<ProductRetrieveDTO> productSearch(
return productSearchUseCase.execute(keyword, pageable);
}

@Operation(summary = "SmallCategory(FE기준 중분류) 별 상품을 조회합니다. (무한스크롤 X)")
@Operation(summary = "SmallCategory(FE기준 중분류) 별 상품을 조회합니다.")
@GetMapping("/products/small-category")
public SliceResponse<ProductRetrieveDTO> getCategoricalProduct(
@ParameterObject ProductFilterCondition productFilterCondition, Pageable pageable) {
public SliceResponse<ProductRetrieveVo> getCategoricalProduct(
@ParameterObject ProductFilterCondition productFilterCondition,
@ParameterObject @PageableDefault(size = 10) Pageable pageable) {
return retrieveProductListUseCase.executeToSmallCategory(productFilterCondition, pageable);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.transaction.annotation.Transactional;
import tify.server.api.common.slice.SliceResponse;
import tify.server.api.product.model.dto.ProductFilterCondition;
import tify.server.api.product.model.vo.ProductRetrieveVo;
import tify.server.core.annotation.UseCase;
import tify.server.domain.domains.product.adaptor.ProductAdaptor;
import tify.server.domain.domains.product.domain.PriceFilter;
Expand All @@ -28,7 +29,7 @@ public class RetrieveProductListUseCase {
private final FavorQuestionAdaptor favorQuestionAdaptor;

@Transactional(readOnly = true)
public SliceResponse<ProductRetrieveDTO> executeToSmallCategory(
public SliceResponse<ProductRetrieveVo> executeToSmallCategory(
ProductFilterCondition productFilterCondition, Pageable pageable) {
List<Long> categoryIdList = new ArrayList<>();
productFilterCondition
Expand All @@ -50,12 +51,14 @@ public SliceResponse<ProductRetrieveDTO> executeToSmallCategory(
pageable));
if (productFilterCondition.getPriceOrder().equals(PriceOrder.DEFAULT)
&& productFilterCondition.getPriceFilter().equals(PriceFilter.DEFAULT)) {
List<ProductRetrieveDTO> result = productRetrieveDTOS.toList();
Collections.shuffle(result);

Slice<ProductRetrieveDTO> shuffledResult = new SliceImpl<>(result, pageable, true);
return SliceResponse.of(shuffledResult);
// TODO : 추천 전략을 적용하는 부분일듯
List<ProductRetrieveDTO> list = productRetrieveDTOS.toList();
Collections.shuffle(list);
return SliceResponse.of(
new SliceImpl<>(list.stream().map(ProductRetrieveVo::from).toList()));
}
return SliceResponse.of(productRetrieveDTOS);
return SliceResponse.of(
new SliceImpl<>(
productRetrieveDTOS.stream().map(ProductRetrieveVo::from).toList()));
}
}

0 comments on commit eef0ff0

Please sign in to comment.