Skip to content

Commit

Permalink
feat: 키워드 검색 기능 추가 (#72)
Browse files Browse the repository at this point in the history
- 기존 활동 조회 API에 키워드 검색 기능 추가
  • Loading branch information
5win authored Nov 9, 2024
1 parent 99e19f5 commit 88cceb3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public Slice<ActivityFindSliceResponse> findSlice(
@RequestParam(required = false) Integer sidoCode,
@RequestParam(defaultValue = "false") boolean teenPossibleOnly,
@RequestParam(defaultValue = "false") boolean beforeDeadlineOnly,
@RequestParam(required = false) String keyword,
Pageable pageable) {

ActivityFilterRequest request = ActivityFilterRequest.builder()
Expand All @@ -41,6 +42,7 @@ public Slice<ActivityFindSliceResponse> findSlice(
.sidoCode(sidoCode)
.teenPossibleOnly(teenPossibleOnly)
.beforeDeadlineOnly(beforeDeadlineOnly)
.keyword(keyword)
.build();

return activityService.findSlice(request, pageable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ public class ActivityFilterRequest {

// 마감되지 않은 활동만
private final boolean beforeDeadlineOnly;

// 키워드 검색
private final String keyword;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public static BooleanBuilder createFilter(ActivityFilterRequest request) {
eqSidoCode(filterBuilder, request.getSidoCode());
isTeenPossibleOnly(filterBuilder, request.isTeenPossibleOnly());
isDeadlineEndOnly(filterBuilder, request.isBeforeDeadlineOnly());
containsKeyword(filterBuilder, request.getKeyword());

return filterBuilder;
}
Expand Down Expand Up @@ -50,4 +51,10 @@ public static void isDeadlineEndOnly(BooleanBuilder filterBuilder, boolean befor
filterBuilder.and(activityJpaEntity.noticeEndDate.after(LocalDateTime.now()));
}
}

public static void containsKeyword(BooleanBuilder filterBuilder, String keyword) {
if (keyword != null) {
filterBuilder.and(activityJpaEntity.actTitle.contains(keyword));
}
}
}

0 comments on commit 88cceb3

Please sign in to comment.