diff --git a/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/domain/repostiory/AuctionItemRepositoryCustomImpl.java b/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/domain/repostiory/AuctionItemRepositoryCustomImpl.java index 14778bb..e66d082 100644 --- a/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/domain/repostiory/AuctionItemRepositoryCustomImpl.java +++ b/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/domain/repostiory/AuctionItemRepositoryCustomImpl.java @@ -42,11 +42,11 @@ public AuctionItemSearchResponse searchAuctionItemPage(SearchAuctionItemSortedRe BooleanBuilder categoryStatus = new BooleanBuilder(); searchAuctionItemSortedRequest.applySearchCategory(categoryStatus, auctionItem); - searchAuctionItemSortedRequest.applySearchStatus(statusBuilder, auctionItem); +// searchAuctionItemSortedRequest.applySearchStatus(statusBuilder, auctionItem); searchAuctionItemSortedRequest.applyKeyWordStatus(keywordStatus, auctionItem); searchAuctionItemSortedRequest.applySearchPrice(orderSpecifiers, auctionItem); - searchAuctionItemSortedRequest.applySearchLike(orderSpecifiers, auctionItem); - searchAuctionItemSortedRequest.applySearchView(orderSpecifiers, auctionItem); +// searchAuctionItemSortedRequest.applySearchLike(orderSpecifiers, auctionItem); +// searchAuctionItemSortedRequest.applySearchView(orderSpecifiers, auctionItem); searchAuctionItemSortedRequest.applySearchTime(orderSpecifiers, auctionItem); searchAuctionItemSortedRequest.applySearchClosed(sellBuilder, auctionItem); @@ -56,8 +56,8 @@ public AuctionItemSearchResponse searchAuctionItemPage(SearchAuctionItemSortedRe .where(auctionItem.removed.eq(false), categoryStatus, statusBuilder, - sellBuilder, - keywordStatus); + keywordStatus, + sellBuilder); Long page = searchAuctionItemSortedRequest.getPage(); int itemsPerPage = 10; diff --git a/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/dto/AuctionItemFirstView.java b/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/dto/AuctionItemFirstView.java index d13624f..90f86c1 100644 --- a/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/dto/AuctionItemFirstView.java +++ b/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/dto/AuctionItemFirstView.java @@ -1,6 +1,8 @@ package megabrain.gyeongnamgyeongmae.domain.auctionItem.dto; import java.time.LocalDateTime; +import java.util.Optional; + import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; @@ -24,7 +26,7 @@ public class AuctionItemFirstView { private LocalDateTime closedTime; - private AuctionItemStatus auctionItemStatus; +// private AuctionItemStatus auctionItemStatus; private AuctionStatus status; @@ -51,10 +53,10 @@ public static AuctionItemFirstView of(AuctionItem auctionItem, Image image) { .view_count(auctionItem.getView_count()) .price(auctionItem.getPrice()) .closedTime(auctionItem.getClosedTime()) - .auctionItemStatus(auctionItem.getItemStatus()) +// .auctionItemStatus(auctionItem.getItemStatus()) .status(auctionItem.getStatus()) .now_price(20000L) - .image_url(image.getImageUrl()) + .image_url(Optional.ofNullable(image).map(Image::getImageUrl).orElse(null)) .build(); } diff --git a/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/dto/CreateAuctionItemRequest.java b/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/dto/CreateAuctionItemRequest.java index c2901ce..0b89fed 100644 --- a/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/dto/CreateAuctionItemRequest.java +++ b/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/dto/CreateAuctionItemRequest.java @@ -23,7 +23,7 @@ public class CreateAuctionItemRequest { @NotNull private String content; - @NotNull private AuctionItemStatus status; +// @NotNull private AuctionItemStatus status; @NotNull private LocalDateTime closedTime; @@ -34,7 +34,7 @@ public AuctionItem toEntity() { .name(this.name) .price(this.price) .content(this.content) - .itemStatus(this.status) +// .itemStatus(this.status) .closedTime(this.closedTime) .build(); } diff --git a/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/dto/SearchItem/SearchAuctionItemSortedRequest.java b/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/dto/SearchItem/SearchAuctionItemSortedRequest.java index 82b087a..82eaa50 100644 --- a/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/dto/SearchItem/SearchAuctionItemSortedRequest.java +++ b/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/dto/SearchItem/SearchAuctionItemSortedRequest.java @@ -15,14 +15,30 @@ @Data public class SearchAuctionItemSortedRequest { + + @NotEmpty private String keyword = null; + + @NotEmpty private String category = null; - private SearchStatus search_status; + +// @NotEmpty +// private SearchStatus search_status; + + @NotEmpty private Boolean closed; + + @NotEmpty private Boolean search_time; - private Boolean like; + +// @NotEmpty +// private Boolean like; + + @NotEmpty private Boolean search_price; - private Boolean view_count; + +// @NotEmpty +// private Boolean view_count; @NotEmpty private Long page; @@ -39,15 +55,15 @@ public void applySearchCategory(BooleanBuilder status, QAuctionItem item) { } } - public void applySearchStatus(BooleanBuilder status, QAuctionItem item) { - if (this.search_status == SearchStatus.NEW) { - status.and(item.itemStatus.eq(AuctionItemStatus.NEW)); - } else if (this.search_status == SearchStatus.USED) { - status.and(item.itemStatus.eq(AuctionItemStatus.USED)); - } else { - status.and(item.itemStatus.in(AuctionItemStatus.NEW, AuctionItemStatus.USED)); - } - } +// public void applySearchStatus(BooleanBuilder status, QAuctionItem item) { +// if (this.search_status == SearchStatus.NEW) { +// status.and(item.itemStatus.eq(AuctionItemStatus.NEW)); +// } else if (this.search_status == SearchStatus.USED) { +// status.and(item.itemStatus.eq(AuctionItemStatus.USED)); +// } else { +// status.and(item.itemStatus.in(AuctionItemStatus.NEW, AuctionItemStatus.USED)); +// } +// } public void applySearchPrice(List> order, QAuctionItem item) { if (this.search_price) { @@ -57,27 +73,27 @@ public void applySearchPrice(List> order, QAuctionItem item) { } } - public void applySearchLike(List> order, QAuctionItem item) { - if (this.like) { - order.add(item.like_count.desc()); - } else { - order.add(item.like_count.asc()); - } - } - - public void applySearchView(List> order, QAuctionItem item) { - if (this.view_count) { - order.add(item.view_count.desc()); - } else { - order.add(item.view_count.asc()); - } - } +// public void applySearchLike(List> order, QAuctionItem item) { +// if (this.like) { +// order.add(item.like_count.desc()); +// } else { +// order.add(item.like_count.asc()); +// } +// } + +// public void applySearchView(List> order, QAuctionItem item) { +// if (this.view_count) { +// order.add(item.view_count.desc()); +// } else { +// order.add(item.view_count.asc()); +// } +// } public void applySearchTime(List> order, QAuctionItem item) { if (this.search_time) { - order.add(item.closedTime.desc()); + order.add(item.createdAt.desc()); } else { - order.add(item.closedTime.asc()); + order.add(item.createdAt.asc()); } } @@ -90,12 +106,12 @@ public void applySearchClosed(BooleanBuilder builder, QAuctionItem item) { } public SearchAuctionItemSortedRequest() { - this.search_status = SearchStatus.ALL; +// this.search_status = SearchStatus.ALL; this.closed = Boolean.FALSE; this.search_time = Boolean.FALSE; - this.like = Boolean.FALSE; +// this.like = Boolean.FALSE; this.search_price = Boolean.FALSE; - this.view_count = Boolean.FALSE; +// this.view_count = Boolean.FALSE; } } diff --git a/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/service/Search/AuctionItemSearchServiceImpl.java b/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/service/Search/AuctionItemSearchServiceImpl.java index 9bd3d21..c3f6912 100644 --- a/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/service/Search/AuctionItemSearchServiceImpl.java +++ b/src/main/java/megabrain/gyeongnamgyeongmae/domain/auctionItem/service/Search/AuctionItemSearchServiceImpl.java @@ -12,13 +12,19 @@ @RequiredArgsConstructor public class AuctionItemSearchServiceImpl implements AuctionItemSearchService { - private final CategoryService categoryService; - private final AuctionItemRepository auctionItemRepository; + private final CategoryService categoryService; + private final AuctionItemRepository auctionItemRepository; - @Override - @Transactional(readOnly = true) - public AuctionItemSearchResponse findAuctionItemByRequest( - SearchAuctionItemSortedRequest searchAuctionItemSortedRequest) { - return auctionItemRepository.searchAuctionItemPage(searchAuctionItemSortedRequest); - } + @Override + @Transactional(readOnly = true) + public AuctionItemSearchResponse findAuctionItemByRequest( + SearchAuctionItemSortedRequest searchAuctionItemSortedRequest) { + if (searchAuctionItemSortedRequest.getKeyword().equals("")) { + searchAuctionItemSortedRequest.setKeyword(null); + } + if (searchAuctionItemSortedRequest.getCategory().equals("")) { + searchAuctionItemSortedRequest.setCategory(null); + } + return auctionItemRepository.searchAuctionItemPage(searchAuctionItemSortedRequest); + } }