Skip to content

Commit 5bece16

Browse files
committed
feat: 지원자 상세 조회 로직 구현
1 parent 45020d9 commit 5bece16

File tree

3 files changed

+38
-6
lines changed

3 files changed

+38
-6
lines changed

src/main/java/dmu/dasom/api/domain/applicant/service/ApplicantService.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dmu.dasom.api.domain.applicant.service;
22

33
import dmu.dasom.api.domain.applicant.dto.ApplicantCreateRequestDto;
4+
import dmu.dasom.api.domain.applicant.dto.ApplicantDetailsResponseDto;
45
import dmu.dasom.api.domain.applicant.dto.ApplicantResponseDto;
56
import dmu.dasom.api.global.dto.PageResponse;
67

@@ -10,4 +11,6 @@ public interface ApplicantService {
1011

1112
PageResponse<ApplicantResponseDto> getApplicants(final int page);
1213

14+
ApplicantDetailsResponseDto getApplicant(final Long id);
15+
1316
}

src/main/java/dmu/dasom/api/domain/applicant/service/ApplicantServiceImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dmu.dasom.api.domain.applicant.service;
22

33
import dmu.dasom.api.domain.applicant.dto.ApplicantCreateRequestDto;
4+
import dmu.dasom.api.domain.applicant.dto.ApplicantDetailsResponseDto;
45
import dmu.dasom.api.domain.applicant.dto.ApplicantResponseDto;
56
import dmu.dasom.api.domain.applicant.entity.Applicant;
67
import dmu.dasom.api.domain.applicant.repository.ApplicantRepository;
@@ -38,4 +39,12 @@ public PageResponse<ApplicantResponseDto> getApplicants(final int page) {
3839
return PageResponse.from(applicants.map(Applicant::toApplicantResponse));
3940
}
4041

42+
// 지원자 상세 조회
43+
@Override
44+
public ApplicantDetailsResponseDto getApplicant(final Long id) {
45+
return applicantRepository.findById(id)
46+
.map(Applicant::toApplicantDetailsResponse)
47+
.orElseThrow(() -> new CustomException(ErrorCode.EMPTY_RESULT));
48+
}
49+
4150
}

src/main/java/dmu/dasom/api/global/admin/controller/AdminController.java

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dmu.dasom.api.global.admin.controller;
22

3+
import dmu.dasom.api.domain.applicant.dto.ApplicantDetailsResponseDto;
34
import dmu.dasom.api.domain.applicant.dto.ApplicantResponseDto;
45
import dmu.dasom.api.domain.applicant.service.ApplicantService;
56
import dmu.dasom.api.global.dto.PageResponse;
@@ -13,10 +14,7 @@
1314
import lombok.RequiredArgsConstructor;
1415
import org.springframework.http.ResponseEntity;
1516
import org.springframework.web.ErrorResponse;
16-
import org.springframework.web.bind.annotation.GetMapping;
17-
import org.springframework.web.bind.annotation.RequestMapping;
18-
import org.springframework.web.bind.annotation.RequestParam;
19-
import org.springframework.web.bind.annotation.RestController;
17+
import org.springframework.web.bind.annotation.*;
2018

2119
@RestController
2220
@RequestMapping("/api/admin")
@@ -26,7 +24,7 @@ public class AdminController {
2624
private final ApplicantService applicantService;
2725

2826
// 지원자 조회
29-
@Operation(summary = "지원자 조회")
27+
@Operation(summary = "지원자 전체 조회")
3028
@ApiResponses(value = {
3129
@ApiResponse(responseCode = "200", description = "지원자 조회 성공"),
3230
@ApiResponse(responseCode = "400", description = "잘못된 요청",
@@ -36,7 +34,7 @@ public class AdminController {
3634
examples = {
3735
@ExampleObject(
3836
name = "조회 결과 없음",
39-
value = "{ \"code\": \"C011\", \"message\": \"조회 결과가 없습니다.\" }"
37+
value = "{ \"code\": \"C012\", \"message\": \"조회 결과가 없습니다.\" }"
4038
)
4139
}
4240
)
@@ -49,4 +47,26 @@ public ResponseEntity<PageResponse<ApplicantResponseDto>> getApplicants(
4947
return ResponseEntity.ok(applicantService.getApplicants(page));
5048
}
5149

50+
// 지원자 상세 조회
51+
@Operation(summary = "지원자 상세 조회")
52+
@ApiResponses(value = {
53+
@ApiResponse(responseCode = "200", description = "지원자 상세 조회 성공"),
54+
@ApiResponse(responseCode = "400", description = "잘못된 요청",
55+
content = @Content(
56+
mediaType = "application/json",
57+
schema = @Schema(implementation = ErrorResponse.class),
58+
examples = {
59+
@ExampleObject(
60+
name = "조회 결과 없음",
61+
value = "{ \"code\": \"C012\", \"message\": \"조회 결과가 없습니다.\" }"
62+
)
63+
}
64+
)
65+
)
66+
})
67+
@GetMapping("/applicants/{id}")
68+
public ResponseEntity<ApplicantDetailsResponseDto> getApplicant(@PathVariable("id") @Min(0) final Long id) {
69+
return ResponseEntity.ok(applicantService.getApplicant(id));
70+
}
71+
5272
}

0 commit comments

Comments
 (0)