Skip to content

Commit

Permalink
[SL-15 CHORE] GET application 반환 형식 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
jinyoungpark00 committed Jan 2, 2024
1 parent 4daa3be commit 525a2b1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ public class ApplicationController {

@Operation(summary = "지원서 정보 가져오기 (저장된 지원서가 없을 시(applicationId = 0), 지원서 1페이지 질문 가져오기)")
@GetMapping("/{applicationId}")
public ResponseEntity<?> getApplication(
public Object getApplication(
@PathVariable(required = false) Long applicationId,
@RequestParam(required = false) Integer page,
Principal principal) {
if (applicationId == null || applicationId == 0) {
return ResponseEntity.ok(applicationService.getApplicationPersonalInformation());
return applicationService.getApplicationPersonalInformation();
} else {
return ResponseEntity.ok(applicationService.getById(applicationId, page, UserUtil.getUserId(principal)));
return applicationService.getById(applicationId, page, UserUtil.getUserId(principal));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,23 +50,24 @@ public ApplicationPage1GetResponse getApplicationPersonalInformation() {
}

// 저장된 지원서 있을 시, 지원서 정보 가져오기
public ResponseEntity<?> getById(Long applicationId, int page, Long userId) {
// 저장된 지원서 있을 시, 지원서 정보 가져오기
public Object getById(Long applicationId, int page, Long userId) {
Application application = applicationJpaRepository.findById(applicationId)
.orElseThrow(() -> new IllegalArgumentException("해당 applicationId를 가진 지원서가 존재하지 않습니다."));

checkApplicationOwner(application, userId);

switch (page) {
case 1:
return ResponseEntity.ok(ApplicationPage1GetResponse.of(application));
return ApplicationPage1GetResponse.of(application);
case 2:
return ResponseEntity.ok(ApplicationPage2GetResponse.of(application.getAnswer()
return ApplicationPage2GetResponse.of(application.getAnswer()
, commonQuestionRepository.findByGeneration(application.getGeneration().getGeneration())
.orElseThrow(() -> new IllegalArgumentException("해당 generation을 가진 commonQuestion이 존재하지 않습니다."))));
.orElseThrow(() -> new IllegalArgumentException("해당 generation을 가진 commonQuestion이 존재하지 않습니다.")));
case 3:
return ResponseEntity.ok(ApplicationPage3GetResponse.of(application.getAnswer(), application.getPart().getPartQuestions(), application.getPortfolio()));
return ApplicationPage3GetResponse.of(application.getAnswer(), application.getPart().getPartQuestions(), application.getPortfolio());
case 4:
return ResponseEntity.ok(ApplicationPage4GetResponse.of(application.getInterviewTimes()));
return ApplicationPage4GetResponse.of(application.getInterviewTimes());
default:
throw new IllegalArgumentException("페이지 번호가 잘못되었습니다.");
}
Expand Down

0 comments on commit 525a2b1

Please sign in to comment.