Skip to content

Commit

Permalink
검색기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomeo184 committed Jan 8, 2024
1 parent 0f24161 commit f20d170
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ public class PostReadParams {
private int maxPrice = Integer.MAX_VALUE;
private Long lastId;
private int limit = 30;
private String searchKeyword;
}
5 changes: 5 additions & 0 deletions src/main/java/com/offer/post/domain/PostQueryRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public PostSummaries searchPost(PostReadParams params, Long loginMemberId) {
categoryEq(params.getCategory()),
priceBetween(params.getMinPrice(), params.getMaxPrice()),
sellerEq(seller),
keywordContains(params.getSearchKeyword()),
tradeStatus(TradeStatus.from(params.getTradeStatus()))
)
.orderBy(order(params.getSort()))
Expand Down Expand Up @@ -139,4 +140,8 @@ private BooleanExpression priceLoe(Integer maxPrice) {
private BooleanExpression priceBetween(Integer minPrice, Integer maxPrice) {
return priceGoe(minPrice).and(priceLoe(maxPrice));
}

private BooleanExpression keywordContains(String searchKeyword) {
return StringUtils.hasText(searchKeyword) ? post.title.contains(searchKeyword) : null;
}
}

0 comments on commit f20d170

Please sign in to comment.