Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 키워드 검색 기능 추가 #72

Merged
merged 1 commit into from
Nov 9, 2024
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 @@ -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));
}
}
}
Loading