Skip to content

Commit 61e2750

Browse files
committed
refactor(recruit-board): 위치 기반 조회시 status 조건 검색 추가
- 기본값 모집중
1 parent 4837aa7 commit 61e2750

File tree

3 files changed

+66
-61
lines changed

3 files changed

+66
-61
lines changed

src/main/java/com/somemore/recruitboard/controller/RecruitBoardQueryApiController.java

Lines changed: 60 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -36,106 +36,108 @@ public class RecruitBoardQueryApiController {
3636
@GetMapping("/recruit-board/{id}")
3737
@Operation(summary = "봉사 모집글 상세 조회", description = "특정 모집글의 상세 정보를 조회합니다.")
3838
public ApiResponse<RecruitBoardWithLocationResponseDto> getById(
39-
@PathVariable Long id
39+
@PathVariable Long id
4040
) {
4141
return ApiResponse.ok(
42-
200,
43-
recruitBoardQueryUseCase.getWithLocationById(id),
44-
"봉사 활동 모집 상세 조회 성공"
42+
200,
43+
recruitBoardQueryUseCase.getWithLocationById(id),
44+
"봉사 활동 모집 상세 조회 성공"
4545
);
4646
}
4747

4848
@GetMapping("/recruit-boards")
4949
@Operation(summary = "전체 모집글 조회", description = "모든 봉사 모집글 목록을 조회합니다.")
5050
public ApiResponse<Page<RecruitBoardWithCenterResponseDto>> getAll(
51-
@PageableDefault(sort = "created_at", direction = DESC)
52-
Pageable pageable
51+
@PageableDefault(sort = "created_at", direction = DESC)
52+
Pageable pageable
5353
) {
5454
RecruitBoardSearchCondition condition = RecruitBoardSearchCondition.builder()
55-
.pageable(pageable)
56-
.build();
55+
.pageable(pageable)
56+
.build();
5757

5858
return ApiResponse.ok(
59-
200,
60-
recruitBoardQueryUseCase.getAllWithCenter(condition),
61-
"봉사 활동 모집글 리스트 조회 성공"
59+
200,
60+
recruitBoardQueryUseCase.getAllWithCenter(condition),
61+
"봉사 활동 모집글 리스트 조회 성공"
6262
);
6363
}
6464

6565
@GetMapping("/recruit-boards/search")
6666
@Operation(summary = "모집글 검색 조회", description = "검색 조건을 기반으로 모집글을 조회합니다.")
6767
public ApiResponse<Page<RecruitBoardWithCenterResponseDto>> getAllBySearch(
68-
@PageableDefault(sort = "created_at", direction = DESC) Pageable pageable,
69-
@RequestParam(required = false) String keyword,
70-
@RequestParam(required = false) VolunteerCategory category,
71-
@RequestParam(required = false) String region,
72-
@RequestParam(required = false) Boolean admitted,
73-
@RequestParam(required = false) RecruitStatus status
68+
@PageableDefault(sort = "created_at", direction = DESC) Pageable pageable,
69+
@RequestParam(required = false) String keyword,
70+
@RequestParam(required = false) VolunteerCategory category,
71+
@RequestParam(required = false) String region,
72+
@RequestParam(required = false) Boolean admitted,
73+
@RequestParam(required = false) RecruitStatus status
7474
) {
7575
RecruitBoardSearchCondition condition = RecruitBoardSearchCondition.builder()
76-
.keyword(keyword)
77-
.category(category)
78-
.region(region)
79-
.admitted(admitted)
80-
.status(status)
81-
.pageable(pageable)
82-
.build();
76+
.keyword(keyword)
77+
.category(category)
78+
.region(region)
79+
.admitted(admitted)
80+
.status(status)
81+
.pageable(pageable)
82+
.build();
8383

8484
return ApiResponse.ok(
85-
200,
86-
recruitBoardQueryUseCase.getAllWithCenter(condition),
87-
"봉사 활동 모집글 검색 조회 성공"
85+
200,
86+
recruitBoardQueryUseCase.getAllWithCenter(condition),
87+
"봉사 활동 모집글 검색 조회 성공"
8888
);
8989
}
9090

9191
@GetMapping("/recruit-boards/nearby")
9292
@Operation(summary = "근처 모집글 조회", description = "주변 반경 내의 봉사 모집글을 조회합니다.")
9393
public ApiResponse<Page<RecruitBoardDetailResponseDto>> getNearby(
94-
@RequestParam double latitude,
95-
@RequestParam double longitude,
96-
@RequestParam(required = false, defaultValue = "5") double radius,
97-
@RequestParam(required = false) String keyword,
98-
@PageableDefault(sort = "created_at", direction = DESC) Pageable pageable
94+
@RequestParam double latitude,
95+
@RequestParam double longitude,
96+
@RequestParam(required = false, defaultValue = "5") double radius,
97+
@RequestParam(required = false) String keyword,
98+
@RequestParam(required = false, defaultValue = "RECRUITING") RecruitStatus status,
99+
@PageableDefault(sort = "created_at", direction = DESC) Pageable pageable
99100
) {
100101
RecruitBoardNearByCondition condition = RecruitBoardNearByCondition.builder()
101-
.latitude(latitude)
102-
.longitude(longitude)
103-
.radius(radius)
104-
.keyword(keyword)
105-
.pageable(pageable)
106-
.build();
102+
.latitude(latitude)
103+
.longitude(longitude)
104+
.radius(radius)
105+
.keyword(keyword)
106+
.status(status)
107+
.pageable(pageable)
108+
.build();
107109

108110
return ApiResponse.ok(
109-
200,
110-
recruitBoardQueryUseCase.getRecruitBoardsNearby(condition),
111-
"근처 봉사 활동 모집글 조회 성공"
111+
200,
112+
recruitBoardQueryUseCase.getRecruitBoardsNearby(condition),
113+
"근처 봉사 활동 모집글 조회 성공"
112114
);
113115
}
114116

115117
@GetMapping("/recruit-boards/center/{centerId}")
116118
@Operation(summary = "특정 기관 모집글 조회", description = "특정 기관의 봉사 모집글을 조회합니다.")
117119
public ApiResponse<Page<RecruitBoardResponseDto>> getRecruitBoardsByCenterId(
118-
@PathVariable UUID centerId,
119-
@PageableDefault(sort = "created_at", direction = DESC) Pageable pageable,
120-
@RequestParam(required = false) String keyword,
121-
@RequestParam(required = false) VolunteerCategory category,
122-
@RequestParam(required = false) String region,
123-
@RequestParam(required = false) Boolean admitted,
124-
@RequestParam(required = false) RecruitStatus status
120+
@PathVariable UUID centerId,
121+
@PageableDefault(sort = "created_at", direction = DESC) Pageable pageable,
122+
@RequestParam(required = false) String keyword,
123+
@RequestParam(required = false) VolunteerCategory category,
124+
@RequestParam(required = false) String region,
125+
@RequestParam(required = false) Boolean admitted,
126+
@RequestParam(required = false) RecruitStatus status
125127
) {
126128
RecruitBoardSearchCondition condition = RecruitBoardSearchCondition.builder()
127-
.keyword(keyword)
128-
.category(category)
129-
.region(region)
130-
.admitted(admitted)
131-
.status(status)
132-
.pageable(pageable)
133-
.build();
129+
.keyword(keyword)
130+
.category(category)
131+
.region(region)
132+
.admitted(admitted)
133+
.status(status)
134+
.pageable(pageable)
135+
.build();
134136

135137
return ApiResponse.ok(
136-
200,
137-
recruitBoardQueryUseCase.getRecruitBoardsByCenterId(centerId, condition),
138-
"기관 봉사 활동 모집글 조회 성공"
138+
200,
139+
recruitBoardQueryUseCase.getRecruitBoardsByCenterId(centerId, condition),
140+
"기관 봉사 활동 모집글 조회 성공"
139141
);
140142
}
141143
}

src/main/java/com/somemore/recruitboard/dto/condition/RecruitBoardNearByCondition.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.somemore.recruitboard.dto.condition;
22

3+
import com.somemore.recruitboard.domain.RecruitStatus;
34
import lombok.Builder;
45
import org.springframework.data.domain.Pageable;
56

@@ -9,6 +10,7 @@ public record RecruitBoardNearByCondition(
910
Double longitude,
1011
Double radius,
1112
String keyword,
13+
RecruitStatus status,
1214
Pageable pageable
1315
) {
1416

src/main/java/com/somemore/recruitboard/repository/RecruitBoardRepositoryImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,10 @@ public Page<RecruitBoardDetail> findAllNearby(RecruitBoardNearByCondition condit
140140

141141
Pageable pageable = condition.pageable();
142142

143-
BooleanExpression predicate = isNotDeleted()
144-
.and(locationBetween(condition))
145-
.and(keywordEq(condition.keyword()));
143+
BooleanExpression predicate = locationBetween(condition)
144+
.and(keywordEq(condition.keyword()))
145+
.and(statusEq(condition.status()))
146+
.and(isNotDeleted());
146147

147148
List<RecruitBoardDetail> content = queryFactory
148149
.select(getRecruitBoardDetailConstructorExpression(recruitBoard, location, center))

0 commit comments

Comments
 (0)