Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public static ProductResponseDTO.ProductListItemDTO toProductListItemDTO(Product
.manufacturer(product.getManufacturer())
.productName(product.getProductName())
.productImage(product.getProductImage())
.decodeStatus(product.getDecodeStatus())
.build();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.DecodEat.domain.products.repository;

import com.DecodEat.domain.products.entity.DecodeStatus;
import com.DecodEat.domain.products.entity.Product;
import com.DecodEat.domain.products.entity.ProductNutrition;
import com.DecodEat.domain.products.entity.ProductRawMaterial;
Expand All @@ -13,6 +14,11 @@
import java.util.List;

public class ProductSpecification {
public static Specification<Product> isCompleted() {
return (root, query, cb) -> cb.equal(root.get("decodeStatus"), DecodeStatus.COMPLETED);
}


// 상품 이름으로 검색
public static Specification<Product> likeProductName(String productName) {
return (root, query, criteriaBuilder) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public ProductResponseDTO.ProductListResultDTO getProducts(Long cursorId) {

public List<ProductSearchResponseDto.SearchResultPrevDto> searchProducts(String productName) {

Specification<Product> spec = Specification.where(null);
Specification<Product> spec = Specification.where(ProductSpecification.isCompleted());

if (StringUtils.hasText(productName)) {
spec = spec.and(ProductSpecification.likeProductName(productName));
Expand All @@ -120,7 +120,7 @@ public List<ProductSearchResponseDto.SearchResultPrevDto> searchProducts(String

public PageResponseDto<ProductSearchResponseDto.ProductPrevDto> searchProducts(String productName, List<RawMaterialCategory> categories, Pageable pageable) {
// Specification을 조합
Specification<Product> spec = Specification.where(null);
Specification<Product> spec = Specification.where(ProductSpecification.isCompleted());

if (StringUtils.hasText(productName)) {
spec = spec.and(ProductSpecification.likeProductName(productName));
Expand Down
Loading