From 84d6727bca09cfaf7d3a9f0fea01cc51b530ceb7 Mon Sep 17 00:00:00 2001 From: unanchoi Date: Mon, 15 Jan 2024 11:25:35 +0900 Subject: [PATCH] =?UTF-8?q?[CHORE]=20primitive=20type=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EA=B5=90=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/swagger/ApplicationApi.java | 8 ++++++-- .../repository/UserJpaRepository.java | 2 +- .../service/ApplicationCommandService.java | 14 +++++++------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/startlion/startlionserver/controller/swagger/ApplicationApi.java b/src/main/java/com/startlion/startlionserver/controller/swagger/ApplicationApi.java index f7c6806..c8f1268 100644 --- a/src/main/java/com/startlion/startlionserver/controller/swagger/ApplicationApi.java +++ b/src/main/java/com/startlion/startlionserver/controller/swagger/ApplicationApi.java @@ -1,10 +1,12 @@ package com.startlion.startlionserver.controller.swagger; import com.startlion.startlionserver.dto.request.application.*; +import com.startlion.startlionserver.dto.response.ErrorResponse; import com.startlion.startlionserver.dto.response.application.ApplicationCreateResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; @@ -29,12 +31,14 @@ ResponseEntity createApplication( @RequestBody ApplicationCreateRequest request, Principal principal); - @Operation(summary = "지원서 업데이트 1페이지") + @Operation(summary = "지원서 1페이지 정보를 저장합니다.") @ApiResponses( value = { @ApiResponse(responseCode = "204", description = "지원서 저장하기 성공"), @ApiResponse(responseCode = "403", description = "권한 없음", content = @Content), - @ApiResponse(responseCode = "404", description = "지원서 정보 없음", content = @Content) + @ApiResponse(responseCode = "404", description = "지원서 정보 없음", content = @Content), + @ApiResponse(responseCode = "500", description = "알 수 없는 서버 에러", content = @Content(contentSchema = @Schema(implementation = ErrorResponse.class) + )) } ) ResponseEntity updateApplicationPage1( diff --git a/src/main/java/com/startlion/startlionserver/repository/UserJpaRepository.java b/src/main/java/com/startlion/startlionserver/repository/UserJpaRepository.java index 0fe7829..411c7b7 100644 --- a/src/main/java/com/startlion/startlionserver/repository/UserJpaRepository.java +++ b/src/main/java/com/startlion/startlionserver/repository/UserJpaRepository.java @@ -9,7 +9,7 @@ public interface UserJpaRepository extends JpaRepository { Optional findByEmail(String email); - default User findByIdOrThrow(Long id) { + default User findByIdOrThrow(long id) { return findById(id).orElseThrow(() -> new UnauthorizedException("인증되지 않은 유저입니다.")); } diff --git a/src/main/java/com/startlion/startlionserver/service/ApplicationCommandService.java b/src/main/java/com/startlion/startlionserver/service/ApplicationCommandService.java index b83a114..0ffb6dc 100644 --- a/src/main/java/com/startlion/startlionserver/service/ApplicationCommandService.java +++ b/src/main/java/com/startlion/startlionserver/service/ApplicationCommandService.java @@ -24,14 +24,14 @@ public class ApplicationCommandService { @Value("${current-generation}") private int currentGeneration; - public ApplicationCreateResponse createApplication(ApplicationCreateRequest request, Long userId) { + public ApplicationCreateResponse createApplication(ApplicationCreateRequest request, final long userId) { val user = userJpaRepository.findByIdOrThrow(userId); val application = Application.create(request, user, currentGeneration); applicationJpaRepository.save(application); return ApplicationCreateResponse.of(application); } - public void updateApplicationPage1(Long applicationId, ApplicationPage1Request request, Long userId) { + public void updateApplicationPage1(Long applicationId, ApplicationPage1Request request, final long userId) { if (!request.isAgreed()) { throw new PersonalInfoApproveException("개인정보 수집 및 이용에 동의해주세요."); } @@ -40,31 +40,31 @@ public void updateApplicationPage1(Long applicationId, ApplicationPage1Request r application.updateApplicationPage1(request); } - public void updateApplicationPage2(Long applicationId, ApplicationPage2Request request, Long userId) { + public void updateApplicationPage2(Long applicationId, ApplicationPage2Request request, final long userId) { val application = applicationJpaRepository.findByIdOrThrow(applicationId); application.updateApplicationPage2(request); } - public void updateApplicationPage3(Long applicationId, ApplicationPage3Request request, Long userId) { + public void updateApplicationPage3(Long applicationId, ApplicationPage3Request request, final long userId) { val application = applicationJpaRepository.findByIdOrThrow(applicationId); checkApplicationOwner(application, userId); application.updateApplicationPage3(request); } - public void updateApplicationPage4(Long applicationId, ApplicationPage4Request request, Long userId) { + public void updateApplicationPage4(Long applicationId, ApplicationPage4Request request, final long userId) { val application = applicationJpaRepository.findByIdOrThrow(applicationId); checkApplicationOwner(application, userId); application.updateApplicationPage4(request); } - public void submitApplication(Long applicationId, Long userId) { + public void submitApplication(Long applicationId, long userId) { val application = applicationJpaRepository.findByIdOrThrow(applicationId); checkApplicationOwner(application, userId); application.completeApplication(); } // 본인의 지원서인지 체크 - private void checkApplicationOwner(Application application, Long userId){ + private void checkApplicationOwner(final Application application, final long userId){ val user = userJpaRepository.findByIdOrThrow(userId); if (user.equals(application.getUser())) { throw new AccessDeniedException("해당 지원서의 소유자가 아닙니다.");