11package inha .gdgoc .domain .recruit .controller ;
22
3+ import static inha .gdgoc .domain .recruit .controller .message .RecruitMemberMessage .MEMBER_LIST_RETRIEVED_SUCCESS ;
34import static inha .gdgoc .domain .recruit .controller .message .RecruitMemberMessage .MEMBER_RETRIEVED_SUCCESS ;
45import static inha .gdgoc .domain .recruit .controller .message .RecruitMemberMessage .MEMBER_SAVE_SUCCESS ;
56import static inha .gdgoc .domain .recruit .controller .message .RecruitMemberMessage .PAYMENT_MARKED_COMPLETE_SUCCESS ;
1112import inha .gdgoc .domain .recruit .dto .request .PaymentUpdateRequest ;
1213import inha .gdgoc .domain .recruit .dto .response .CheckPhoneNumberResponse ;
1314import inha .gdgoc .domain .recruit .dto .response .CheckStudentIdResponse ;
15+ import inha .gdgoc .domain .recruit .dto .response .RecruitMemberSummaryResponse ;
1416import inha .gdgoc .domain .recruit .dto .response .SpecifiedMemberResponse ;
17+ import inha .gdgoc .domain .recruit .entity .RecruitMember ;
1518import inha .gdgoc .domain .recruit .service .RecruitMemberService ;
1619import inha .gdgoc .global .dto .response .ApiResponse ;
20+ import inha .gdgoc .global .dto .response .PageMeta ;
1721import io .swagger .v3 .oas .annotations .Operation ;
22+ import io .swagger .v3 .oas .annotations .Parameter ;
1823import io .swagger .v3 .oas .annotations .security .SecurityRequirement ;
1924import io .swagger .v3 .oas .annotations .tags .Tag ;
2025import jakarta .validation .constraints .NotBlank ;
2126import jakarta .validation .constraints .Pattern ;
27+ import java .util .List ;
2228import lombok .RequiredArgsConstructor ;
29+ import org .springframework .data .domain .Page ;
30+ import org .springframework .data .domain .PageRequest ;
31+ import org .springframework .data .domain .Pageable ;
32+ import org .springframework .data .domain .Sort ;
33+ import org .springframework .data .domain .Sort .Direction ;
2334import org .springframework .http .ResponseEntity ;
2435import org .springframework .security .access .prepost .PreAuthorize ;
2536import org .springframework .web .bind .annotation .GetMapping ;
@@ -84,9 +95,6 @@ public ResponseEntity<ApiResponse<SpecifiedMemberResponse, Void>> getSpecifiedMe
8495 return ResponseEntity .ok (ApiResponse .ok (MEMBER_RETRIEVED_SUCCESS , response ));
8596 }
8697
87- // TODO 전체 응답 조회 및 검색
88-
89-
9098 @ Operation (
9199 summary = "입금 상태 변경" ,
92100 description = "설정하려는 상태(NOT 현재 상태)를 body에 보내주세요. true=입금 완료, false=입금 미완료" ,
@@ -109,4 +117,42 @@ public ResponseEntity<ApiResponse<Void, Void>> updatePayment(
109117 );
110118 }
111119
120+ @ Operation (
121+ summary = "지원자 목록 조회" ,
122+ description = "전체 목록 또는 이름 검색 결과를 반환합니다. 검색어(question)를 주면 이름 포함 검색, 없으면 전체 조회. sort랑 dir은 example 값 그대로 코딩하는 것 추천..." ,
123+ security = { @ SecurityRequirement (name = "BearerAuth" ) }
124+ )
125+ @ PreAuthorize ("hasRole('ADMIN')" )
126+ @ GetMapping ("/recruit/members" )
127+ public ResponseEntity <ApiResponse <List <RecruitMemberSummaryResponse >, PageMeta >> getMembers (
128+ @ Parameter (description = "검색어(이름 부분 일치). 없으면 전체 조회" , example = "소연" )
129+ @ RequestParam (required = false ) String question ,
130+
131+ @ Parameter (description = "페이지(0부터 시작)" , example = "0" )
132+ @ RequestParam (defaultValue = "0" ) int page ,
133+
134+ @ Parameter (description = "페이지 크기" , example = "20" )
135+ @ RequestParam (defaultValue = "20" ) int size ,
136+
137+ @ Parameter (description = "정렬 필드" , example = "createdAt" )
138+ @ RequestParam (defaultValue = "createdAt" ) String sort ,
139+
140+ @ Parameter (description = "정렬 방향 ASC/DESC" , example = "DESC" )
141+ @ RequestParam (defaultValue = "DESC" ) String dir
142+ ) {
143+ Direction direction = "ASC" .equalsIgnoreCase (dir ) ? Direction .ASC : Direction .DESC ;
144+ Pageable pageable = PageRequest .of (page , size , Sort .by (direction , sort ));
145+
146+ Page <RecruitMember > memberPage = (question == null || question .isBlank ())
147+ ? recruitMemberService .findAllMembersPage (pageable )
148+ : recruitMemberService .searchMembersByNamePage (question , pageable );
149+
150+ List <RecruitMemberSummaryResponse > list = memberPage
151+ .map (RecruitMemberSummaryResponse ::from )
152+ .getContent ();
153+ PageMeta meta = PageMeta .of (memberPage );
154+
155+ return ResponseEntity .ok (ApiResponse .ok (MEMBER_LIST_RETRIEVED_SUCCESS , list , meta ));
156+ }
157+
112158}
0 commit comments