From a299dfe30289038ae88fbaa8976490f53fdcc80a Mon Sep 17 00:00:00 2001 From: unanchoi Date: Fri, 12 Jan 2024 14:36:44 +0900 Subject: [PATCH] =?UTF-8?q?[FIX]=20=EC=A7=80=EC=9B=90=EC=84=9C=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20API=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ApplicationReadApi.java | 11 +++++++++++ .../controller/ApplicationReadController.java | 14 ++++++++++---- .../application/ApplicationPage1Response.java | 9 +++++++-- .../repository/PathToKnowJpaRepository.java | 2 +- .../service/ApplicationQueryService.java | 10 +++++++++- 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/startlion/startlionserver/controller/ApplicationReadApi.java b/src/main/java/com/startlion/startlionserver/controller/ApplicationReadApi.java index 9418e22..af0bf29 100644 --- a/src/main/java/com/startlion/startlionserver/controller/ApplicationReadApi.java +++ b/src/main/java/com/startlion/startlionserver/controller/ApplicationReadApi.java @@ -33,6 +33,17 @@ ResponseEntity getApplicationById( @PathVariable Long applicationId, Principal principal); + @Operation(summary = "지원서 페이지 1 정보 가져오기") +@ApiResponses( + value = { + @ApiResponse(responseCode = "200", description = "지원서 페이지 1 정보 가져오기 성공"), + @ApiResponse(responseCode = "403", description = "권한 없음"), + @ApiResponse(responseCode = "404", description = "지원서 페이지 1 정보 없음") + } + ) + ResponseEntity getApplicationPage1ById( + @PathVariable Long applicationId, + Principal principal); @Operation(summary = "지원서 페이지 2 정보 가져오기") @ApiResponses( diff --git a/src/main/java/com/startlion/startlionserver/controller/ApplicationReadController.java b/src/main/java/com/startlion/startlionserver/controller/ApplicationReadController.java index 2d0522c..0de91b7 100644 --- a/src/main/java/com/startlion/startlionserver/controller/ApplicationReadController.java +++ b/src/main/java/com/startlion/startlionserver/controller/ApplicationReadController.java @@ -29,14 +29,20 @@ public ResponseEntity getApplications(Principal princip @Override - @GetMapping("{applicationId}") + @GetMapping("/{applicationId}") public ResponseEntity getApplicationById(Long applicationId, Principal principal) { val response = applicationQueryService.getApplication(applicationId, UserUtil.getUserId(principal)); return ResponseEntity.ok(response); } @Override - @GetMapping("{applicationId}/page2") + @GetMapping("/{applicationId}/page1") + public ResponseEntity getApplicationPage1ById(Long applicationId, Principal principal) { + return null; + } + + @Override + @GetMapping("{/applicationId}/page2") public ResponseEntity getApplicationPage2ById(Long applicationId, Principal principal) { val response = applicationQueryService.getApplicationPage2(applicationId, UserUtil.getUserId(principal)); return ResponseEntity.ok(response); @@ -44,14 +50,14 @@ public ResponseEntity getApplicationPage2ById(Long } @Override - @GetMapping("{applicationId}/page3") + @GetMapping("{/applicationId}/page3") public ResponseEntity getApplicationPage3ById(Long applicationId, Principal principal) { val response = applicationQueryService.getApplicationPage3(applicationId, UserUtil.getUserId(principal)); return ResponseEntity.ok(response); } @Override - @GetMapping + @GetMapping("{/applicationId}/page4") public ResponseEntity getApplicationPage4ById(Long applicationId, Principal principal) { val response = applicationQueryService.getApplicationPage4(applicationId, UserUtil.getUserId(principal)); return ResponseEntity.ok(response); diff --git a/src/main/java/com/startlion/startlionserver/dto/response/application/ApplicationPage1Response.java b/src/main/java/com/startlion/startlionserver/dto/response/application/ApplicationPage1Response.java index 75ab8b7..575fddb 100644 --- a/src/main/java/com/startlion/startlionserver/dto/response/application/ApplicationPage1Response.java +++ b/src/main/java/com/startlion/startlionserver/dto/response/application/ApplicationPage1Response.java @@ -5,6 +5,8 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Builder; +import java.util.List; + @Builder @Schema(description = "지원서 페이지 1 응답") @@ -28,10 +30,12 @@ public record ApplicationPage1Response( @Schema(description = "이메일") String email, @Schema(description = "지원 파트") - String part + String part, + @Schema(description = "알게 된 경로") + List pathToKnow ) { - public static ApplicationPage1Response of(Application application) { + public static ApplicationPage1Response of(Application application, List pathToKnow) { return ApplicationPage1Response.builder() .applicationId(application.getApplicationId()) .name(application.getName()) @@ -43,6 +47,7 @@ public static ApplicationPage1Response of(Application application) { .phone(application.getPhone()) .email(application.getEmail()) .part(application.getPart().getName()) + .pathToKnow(pathToKnow) .build(); } } diff --git a/src/main/java/com/startlion/startlionserver/repository/PathToKnowJpaRepository.java b/src/main/java/com/startlion/startlionserver/repository/PathToKnowJpaRepository.java index 3791f50..d7883c2 100644 --- a/src/main/java/com/startlion/startlionserver/repository/PathToKnowJpaRepository.java +++ b/src/main/java/com/startlion/startlionserver/repository/PathToKnowJpaRepository.java @@ -6,7 +6,7 @@ import java.util.List; public interface PathToKnowJpaRepository extends JpaRepository { - List findByApplicationId(Long applicationId); + List findByApplicationId(Long applicationId); void deleteAllByApplicationId(Long applicationId); } diff --git a/src/main/java/com/startlion/startlionserver/service/ApplicationQueryService.java b/src/main/java/com/startlion/startlionserver/service/ApplicationQueryService.java index 34cb5ae..237e2dd 100644 --- a/src/main/java/com/startlion/startlionserver/service/ApplicationQueryService.java +++ b/src/main/java/com/startlion/startlionserver/service/ApplicationQueryService.java @@ -12,7 +12,10 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.List; + import static com.startlion.startlionserver.dto.response.question.CommonQuestionResponse.*; +import static java.util.Arrays.stream; @Service @RequiredArgsConstructor @@ -24,11 +27,16 @@ public class ApplicationQueryService { private final PartQuestionJpaRepository partQuestionJpaRepository; private final CommonQuestionJpaRepository commonQuestionRepository; private final CurrentGenerationRepository currentGenerationRepository; + private final PathToKnowJpaRepository pathToKnowJpaRepository; public ApplicationPage1Response getApplicationPage1(Long applicationId, Long userId) { val application = applicationJpaRepository.findByIdOrThrow(applicationId); + val pathToKnow = pathToKnowJpaRepository.findByApplicationId(applicationId); checkApplicationOwner(application, userId); - return ApplicationPage1Response.of(application); + List pathToKnows = pathToKnow.stream() + .map(p -> p.getPathType().getName()) + .toList(); + return ApplicationPage1Response.of(application, pathToKnows); } public ApplicationPage2GetResponse getApplicationPage2(Long applicationId, Long userId) {