Skip to content

Commit 4f50d17

Browse files
authored
feat: 관리자 지원서 조회 API에 기수 파라미터 추가 (#409)
* feat: 임시 지원서 목록 조회 API에 semesterId 필터 추가 * feat: 제출된 지원서 조회 API에 semesterId 필터 추가 * feat: 제출된 지원서 조회 API에 semesterId 파라미터 추가 * feat: 임시 지원서 조회 API에 semesterId 파라미터 추가 * feat: 지원서 조회 쿼리에 semesterId 파라미터 추가 및 필터링 로직 구현 * test: 지원서 조회 테스트에 semesterId 필터링 테스트 추가
1 parent 810aef9 commit 4f50d17

11 files changed

Lines changed: 154 additions & 33 deletions

File tree

src/main/java/org/ject/support/domain/admin/controller/AdminTempApplyApiSpec.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public interface AdminTempApplyApiSpec {
3737
)
3838
Page<TempSavedApplyResponse> getTempApplies(
3939
@RequestParam(required = false) JobFamily jobFamily,
40+
@RequestParam(required = false) final Long semesterId,
4041
@PageableDefault(size = 15) final Pageable pageable
4142
);
4243
}

src/main/java/org/ject/support/domain/admin/controller/AdminTempApplyController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ public void deleteTempApply(@PathVariable final Long tempApplyId) {
4040

4141
@GetMapping()
4242
public Page<TempSavedApplyResponse> getTempApplies(@RequestParam(required = false) JobFamily jobFamily,
43+
@RequestParam(required = false) final Long semesterId,
4344
@PageableDefault(size = 15) Pageable pageable) {
44-
return adminTempApplyService.getTempApplies(jobFamily, pageable);
45+
return adminTempApplyService.getTempApplies(jobFamily, semesterId, pageable);
4546
}
4647
}

src/main/java/org/ject/support/domain/admin/controller/SubmittedApplyApiSpec.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public interface SubmittedApplyApiSpec {
2828
summary = "제출된 지원서 목록 조회",
2929
description = "제출된 지원서들의 목록을 조회합니다.")
3030
Page<SubmittedApplyResponse> findSubmittedApplies(@RequestParam(required = false) final JobFamily jobFamily,
31+
@RequestParam(required = false) final Long semesterId,
3132
@PageableDefault(size = 15) final Pageable pageable);
3233

3334
@Operation(

src/main/java/org/ject/support/domain/admin/controller/SubmittedApplyController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ public SubmittedApplyCountResponse getSubmittedApplyCount() {
3737
@Override
3838
@GetMapping
3939
public Page<SubmittedApplyResponse> findSubmittedApplies(@RequestParam(required = false) final JobFamily jobFamily,
40+
@RequestParam(required = false) final Long semesterId,
4041
@PageableDefault(size = 15) final Pageable pageable) {
41-
return submittedApplyService.findSubmittedApplies(jobFamily, pageable);
42+
return submittedApplyService.findSubmittedApplies(jobFamily, semesterId, pageable);
4243
}
4344

4445
@Override

src/main/java/org/ject/support/domain/admin/service/AdminTempApplyService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ public void deleteTempApply(Long applyId) {
5656
applyRepository.delete(apply);
5757
}
5858

59-
public Page<TempSavedApplyResponse> getTempApplies(JobFamily jobFamily, Pageable pageable) {
59+
public Page<TempSavedApplyResponse> getTempApplies(JobFamily jobFamily, Long semesterId, Pageable pageable) {
6060
Apply.Status tempSavedStatus = Apply.Status.TEMP_SAVED;
61-
Page<Apply> applyPage = applyRepository.findAppliesByStatus(jobFamily, tempSavedStatus, pageable);
61+
Page<Apply> applyPage = applyRepository.findAppliesByStatus(jobFamily, tempSavedStatus, semesterId, pageable);
6262

6363
List<TempSavedApplyResponse> content = applyPage.getContent().stream()
6464
.map(this::toTempSavedApplyResponse)

src/main/java/org/ject/support/domain/admin/service/SubmittedApplyService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ public class SubmittedApplyService {
4141

4242
@Transactional(readOnly = true)
4343
public Page<SubmittedApplyResponse> findSubmittedApplies(final JobFamily jobFamily,
44+
final Long semesterId,
4445
final Pageable pageable) {
45-
Page<Apply> applyPage = applyRepository.findAppliesByStatus(jobFamily, Status.SUBMITTED, pageable);
46+
Page<Apply> applyPage = applyRepository.findAppliesByStatus(jobFamily, Status.SUBMITTED, semesterId, pageable);
4647

4748
List<SubmittedApplyResponse> content = applyPage.getContent().stream()
4849
.map(this::toSubmittedApplyResponse)

src/main/java/org/ject/support/domain/apply/repository/ApplyQueryRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
public interface ApplyQueryRepository {
99
Page<Apply> findAppliesByStatus(final JobFamily jobFamily,
1010
final Apply.Status status,
11+
final Long semesterId,
1112
final Pageable pageable);
1213
}

src/main/java/org/ject/support/domain/apply/repository/ApplyQueryRepositoryImpl.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ public class ApplyQueryRepositoryImpl implements ApplyQueryRepository {
2626

2727
@Override
2828
public Page<Apply> findAppliesByStatus(final JobFamily jobFamily,
29-
final Apply.Status status, final Pageable pageable) {
29+
final Apply.Status status,
30+
final Long semesterId,
31+
final Pageable pageable) {
3032

3133
List<Apply> content = queryFactory
3234
.selectFrom(apply)
@@ -37,7 +39,8 @@ public Page<Apply> findAppliesByStatus(final JobFamily jobFamily,
3739
.where(
3840
apply.member.isDeleted.eq(false),
3941
eqJobFamily(jobFamily),
40-
eqApplyStatus(status)
42+
eqApplyStatus(status),
43+
eqSemesterId(semesterId)
4144
)
4245
.orderBy(apply.createdAt.desc())
4346
.offset(pageable.getOffset())
@@ -51,7 +54,8 @@ public Page<Apply> findAppliesByStatus(final JobFamily jobFamily,
5154
.where(
5255
apply.member.isDeleted.eq(false),
5356
eqJobFamily(jobFamily),
54-
eqApplyStatus(status)
57+
eqApplyStatus(status),
58+
eqSemesterId(semesterId)
5559
).fetchOne();
5660

5761
return PageResponse.from(content, pageable, total);
@@ -67,4 +71,10 @@ private BooleanExpression eqApplyStatus(final Apply.Status status) {
6771
.map(apply.status::eq)
6872
.orElse(null);
6973
}
74+
75+
private BooleanExpression eqSemesterId(final Long semesterId) {
76+
return Optional.ofNullable(semesterId)
77+
.map(apply.recruit.semester.id::eq)
78+
.orElse(null);
79+
}
7080
}

src/test/java/org/ject/support/domain/admin/service/AdminTempApplyServiceTest.java

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,17 @@ class AdminTempApplyServiceTest extends UnitTestSupport {
164164
void 임시_저장된_지원서를_조회할때_결과가_없으면_빈페이지_반환한다() {
165165
// given
166166
Pageable pageable = PageRequest.of(0, 10);
167+
Long semesterId = null;
167168
Page<Apply> applyPage = new PageImpl<>(List.of(), pageable, 0);
168169

169-
given(applyRepository.findAppliesByStatus(null, Apply.Status.TEMP_SAVED, pageable))
170+
given(applyRepository.findAppliesByStatus(null, Apply.Status.TEMP_SAVED, semesterId, pageable))
170171
.willReturn(applyPage);
171172

172173
// when
173-
Page<TempSavedApplyResponse> result = adminTempApplyService.getTempApplies(null, pageable);
174+
Page<TempSavedApplyResponse> result = adminTempApplyService.getTempApplies(null, semesterId, pageable);
174175

175176
// then
176-
verify(applyRepository).findAppliesByStatus(null, Apply.Status.TEMP_SAVED, pageable);
177+
verify(applyRepository).findAppliesByStatus(null, Apply.Status.TEMP_SAVED, semesterId, pageable);
177178
assertThat(result.getTotalElements()).isEqualTo(0);
178179
assertThat(result.getContent()).isEmpty();
179180
}
@@ -182,6 +183,7 @@ class AdminTempApplyServiceTest extends UnitTestSupport {
182183
void 임시_저장된_지원서를_조회_한다() {
183184
// given
184185
Pageable pageable = PageRequest.of(0, 10);
186+
Long semesterId = null;
185187

186188
Member m1 = Member.builder().name("김1").build();
187189
Member m2 = Member.builder().name("김2").build();
@@ -210,20 +212,55 @@ class AdminTempApplyServiceTest extends UnitTestSupport {
210212
List<Apply> applies = List.of(a1, a2);
211213
Page<Apply> applyPage = new PageImpl<>(applies, pageable, applies.size());
212214

213-
given(applyRepository.findAppliesByStatus(null, Apply.Status.TEMP_SAVED, pageable))
215+
given(applyRepository.findAppliesByStatus(null, Apply.Status.TEMP_SAVED, semesterId, pageable))
214216
.willReturn(applyPage);
215217

216218
// applicationForm.content가 "{}" 이므로 이 호출을 stub 처리
217219
given(string2MapSerializer.serializeAsMap("{}")).willReturn(java.util.Map.of());
218220

219221
Page<TempSavedApplyResponse> result =
220-
adminTempApplyService.getTempApplies(null, pageable);
222+
adminTempApplyService.getTempApplies(null, semesterId, pageable);
221223

222-
verify(applyRepository).findAppliesByStatus(null,Apply.Status.TEMP_SAVED, pageable);
224+
verify(applyRepository).findAppliesByStatus(null, Apply.Status.TEMP_SAVED, semesterId, pageable);
223225
assertThat(result.getTotalElements()).isEqualTo(2);
224226
assertThat(result.getContent()).hasSize(2);
225227
assertThat(result.getContent().get(0).applyId()).isEqualTo(1L);
226228
assertThat(result.getContent().get(1).applyId()).isEqualTo(2L);
227229
}
228230

231+
@Test
232+
void 임시_저장된_지원서를_semesterId로_필터링하여_조회한다() {
233+
// given
234+
Pageable pageable = PageRequest.of(0, 10);
235+
Long semesterId = 1L;
236+
237+
Member member = Member.builder().name("김젝트").build();
238+
Semester semester = Semester.builder().name("1").build();
239+
Recruit recruit = Recruit.builder().semester(semester).build();
240+
ApplicationForm form = ApplicationForm.builder().content("{}").build();
241+
242+
Apply apply = Apply.builder()
243+
.id(1L)
244+
.member(member)
245+
.recruit(recruit)
246+
.status(Apply.Status.TEMP_SAVED)
247+
.applicationForm(form)
248+
.build();
249+
250+
List<Apply> applies = List.of(apply);
251+
Page<Apply> applyPage = new PageImpl<>(applies, pageable, applies.size());
252+
253+
given(applyRepository.findAppliesByStatus(null, Apply.Status.TEMP_SAVED, semesterId, pageable))
254+
.willReturn(applyPage);
255+
given(string2MapSerializer.serializeAsMap("{}")).willReturn(java.util.Map.of());
256+
257+
// when
258+
Page<TempSavedApplyResponse> result = adminTempApplyService.getTempApplies(null, semesterId, pageable);
259+
260+
// then
261+
verify(applyRepository).findAppliesByStatus(null, Apply.Status.TEMP_SAVED, semesterId, pageable);
262+
assertThat(result.getTotalElements()).isEqualTo(1);
263+
assertThat(result.getContent()).hasSize(1);
264+
assertThat(result.getContent().get(0).applyId()).isEqualTo(1L);
265+
}
229266
}

src/test/java/org/ject/support/domain/admin/service/SubmittedApplyServiceTest.java

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -219,65 +219,69 @@ void setUp() {
219219
// given
220220
var pageable = PageRequest.of(0, 15);
221221
var jobFamily = JobFamily.BE;
222+
Long semesterId = null;
222223

223224
var applies = List.of(submittedApply);
224225
var page = new PageImpl<>(applies, pageable, 1L);
225226

226-
given(applyRepository.findAppliesByStatus(jobFamily, Status.SUBMITTED ,pageable))
227+
given(applyRepository.findAppliesByStatus(jobFamily, Status.SUBMITTED, semesterId, pageable))
227228
.willReturn(page);
228229

229230
// when
230-
Page<SubmittedApplyResponse> result = submittedApplyService.findSubmittedApplies(jobFamily, pageable);
231+
Page<SubmittedApplyResponse> result = submittedApplyService.findSubmittedApplies(jobFamily, semesterId, pageable);
231232

232233
// then
233234
assertThat(result.getContent()).hasSize(1);
234235
assertThat(result.getTotalElements()).isEqualTo(1);
235-
verify(applyRepository).findAppliesByStatus(jobFamily, Status.SUBMITTED, pageable);
236+
verify(applyRepository).findAppliesByStatus(jobFamily, Status.SUBMITTED, semesterId, pageable);
236237
}
237238

238239
@Test
239240
void 제출된_지원서_목록_조회시_JobFamily가_null이면_전체_조회() {
240241
// given
241242
var pageable = PageRequest.of(0, 15);
243+
Long semesterId = null;
242244
var applies = List.of(submittedApply);
243245
var page = new PageImpl<>(applies, pageable, 1L);
244246

245-
given(applyRepository.findAppliesByStatus(null, Status.SUBMITTED, pageable))
247+
given(applyRepository.findAppliesByStatus(null, Status.SUBMITTED, semesterId, pageable))
246248
.willReturn(page);
247249

248250
// when
249-
Page<SubmittedApplyResponse> result = submittedApplyService.findSubmittedApplies(null, pageable);
251+
Page<SubmittedApplyResponse> result = submittedApplyService.findSubmittedApplies(null, semesterId, pageable);
250252

251253
// then
252254
assertThat(result.getContent()).hasSize(1);
253255
assertThat(result.getTotalElements()).isEqualTo(1);
254-
verify(applyRepository).findAppliesByStatus(null, Status.SUBMITTED, pageable);
256+
verify(applyRepository).findAppliesByStatus(null, Status.SUBMITTED, semesterId, pageable);
255257
}
256258

257259
@Test
258260
void 제출된_지원서_목록_조회시_결과가_없으면_빈_페이지_반환() {
259261
// given
260262
var pageable = PageRequest.of(0, 15);
261263
var jobFamily = JobFamily.BE;
264+
Long semesterId = null;
262265
var page = new PageImpl<Apply>(List.of(), pageable, 0L);
263266

264-
given(applyRepository.findAppliesByStatus(jobFamily, Status.SUBMITTED, pageable))
267+
given(applyRepository.findAppliesByStatus(jobFamily, Status.SUBMITTED, semesterId, pageable))
265268
.willReturn(page);
266269

267270
// when
268-
Page<SubmittedApplyResponse> result = submittedApplyService.findSubmittedApplies(jobFamily, pageable);
271+
Page<SubmittedApplyResponse> result = submittedApplyService.findSubmittedApplies(jobFamily, semesterId, pageable);
269272

270273
// then
271274
assertThat(result.getContent()).isEmpty();
272275
assertThat(result.getTotalElements()).isZero();
273-
verify(applyRepository).findAppliesByStatus(jobFamily, Status.SUBMITTED, pageable);
276+
verify(applyRepository).findAppliesByStatus(jobFamily, Status.SUBMITTED, semesterId, pageable);
274277
}
275278

276279
@Test
277280
void 제출된_지원서_목록_조회시_페이징_정보_정확히_전달() {
278281
// given
279282
var pageable = PageRequest.of(1, 10, Sort.by("createdAt").descending());
280283
var jobFamily = JobFamily.BE;
284+
Long semesterId = null;
281285

282286
var member2 = Member.builder().name("김젝트2").build();
283287
var apply2 = Apply.builder()
@@ -291,18 +295,40 @@ void setUp() {
291295
var applies = List.of(submittedApply, apply2);
292296
var page = new PageImpl<>(applies, pageable, 25L);
293297

294-
given(applyRepository.findAppliesByStatus(jobFamily, Status.SUBMITTED, pageable))
298+
given(applyRepository.findAppliesByStatus(jobFamily, Status.SUBMITTED, semesterId, pageable))
295299
.willReturn(page);
296300

297301
// when
298-
Page<SubmittedApplyResponse> result = submittedApplyService.findSubmittedApplies(jobFamily, pageable);
302+
Page<SubmittedApplyResponse> result = submittedApplyService.findSubmittedApplies(jobFamily, semesterId, pageable);
299303

300304
// then
301305
assertThat(result.getContent()).hasSize(2);
302306
assertThat(result.getTotalElements()).isEqualTo(25L);
303307
assertThat(result.getNumber()).isEqualTo(1);
304308
assertThat(result.getSize()).isEqualTo(10);
305-
verify(applyRepository).findAppliesByStatus(jobFamily, Status.SUBMITTED, pageable);
309+
verify(applyRepository).findAppliesByStatus(jobFamily, Status.SUBMITTED, semesterId, pageable);
310+
}
311+
312+
@Test
313+
void 제출된_지원서_목록을_semesterId로_필터링하여_조회() {
314+
// given
315+
var pageable = PageRequest.of(0, 15);
316+
var jobFamily = JobFamily.BE;
317+
Long semesterId = 1L;
318+
319+
var applies = List.of(submittedApply);
320+
var page = new PageImpl<>(applies, pageable, 1L);
321+
322+
given(applyRepository.findAppliesByStatus(jobFamily, Status.SUBMITTED, semesterId, pageable))
323+
.willReturn(page);
324+
325+
// when
326+
Page<SubmittedApplyResponse> result = submittedApplyService.findSubmittedApplies(jobFamily, semesterId, pageable);
327+
328+
// then
329+
assertThat(result.getContent()).hasSize(1);
330+
assertThat(result.getTotalElements()).isEqualTo(1);
331+
verify(applyRepository).findAppliesByStatus(jobFamily, Status.SUBMITTED, semesterId, pageable);
306332
}
307333

308334
@Test

0 commit comments

Comments
 (0)