Skip to content

Commit

Permalink
Merge pull request #84 from lotteon2/fix/admin-product-property
Browse files Browse the repository at this point in the history
fix: 관리자 상품 조회 수정
  • Loading branch information
indl1670 authored Jan 12, 2024
2 parents 3743913 + 5ce9f2c commit 926a5ab
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,9 @@ public Map<Long, Double> findStoreAverageRating() {
public Page<Product> findProductsForAdmin(
ProductCommand.AdminSelectOption adminSelectOption, Pageable pageable) {
Query query = new Query();
if (adminSelectOption.getStoreId() != null)
query.addCriteria(Criteria.where("store_id").is(adminSelectOption.getStoreId()));
query.addCriteria(Criteria.where("is_subscription").is(false));
if (adminSelectOption.getStatus() != null)
query.addCriteria(Criteria.where("product_sale_status").is(adminSelectOption.getStatus()));

if (adminSelectOption.getDate().equals(SortOption.NEW))
query.with(Sort.by(Order.desc(adminSelectOption.getDate().getSortOption())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,15 +352,15 @@ public CommonResponse<ProductCommand.ProductsForAdmin> getProductsForAdmin(
sort = {"createdAt"},
direction = Sort.Direction.DESC)
Pageable pageable,
@RequestParam("store-id") Optional<Long> storeId,
@RequestParam("status") Optional<ProductSaleStatus> status,
@RequestParam("date") Optional<SortOption> date,
@RequestParam("sales") Optional<SortOption> sales) {
Long storeIdParam = storeId.orElse(null);
ProductSaleStatus statusParam = status.orElse(null);
SortOption dateParam = date.orElse(null);
SortOption salesParam = sales.orElse(null);
ProductsForAdmin productsForAdmin =
productQueryUseCase.getProductsForAdmin(
AdminSelectOption.getData(storeIdParam, dateParam, salesParam), pageable);
AdminSelectOption.getData(statusParam, dateParam, salesParam), pageable);
return CommonResponse.success(productsForAdmin);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,16 +646,16 @@ public static RepresentativeFlowerId getData(Long flowerId) {
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public static class AdminSelectOption {
private Long storeId;
private ProductSaleStatus status;
@Builder.Default private SortOption date = SortOption.NEW;
@Builder.Default private SortOption salesAmount = SortOption.TOP_SALE;

public static AdminSelectOption getData(
Long storeIdParam, SortOption dateParam, SortOption salesParam) {
ProductSaleStatus statusParam, SortOption dateParam, SortOption salesParam) {
return AdminSelectOption.builder()
.salesAmount(salesParam != null ? salesParam : SortOption.TOP_SALE)
.date(dateParam != null ? dateParam : SortOption.NEW)
.storeId(storeIdParam)
.status(statusParam)
.build();
}
}
Expand All @@ -667,22 +667,20 @@ public static AdminSelectOption getData(
public static class ProductsForAdminItem {
private String key;
private Long productPrice;
private String productThumbnail;
private String productName;
private Long productSaleAmount;
private Long storeId;
private String storeName;
private Double averageRating;
private ProductSaleStatus productSaleStatus;
private LocalDateTime createdAt;

public static ProductsForAdminItem getData(Product item, Map<Long, String> storeNameData) {
return ProductsForAdminItem.builder()
.productThumbnail(item.getProductThumbnail())
.productName(item.getProductName())
.key(item.getProductId())
.averageRating(item.getAverageRating())
.productSaleAmount(item.getProductSaleAmount())
.productSaleStatus(item.getProductSaleStatus())
.storeId(item.getStoreId())
.createdAt(item.getCreatedAt())
.storeName(storeNameData.get(item.getStoreId()))
.productPrice(item.getProductPrice())
Expand Down

0 comments on commit 926a5ab

Please sign in to comment.