Skip to content

Commit

Permalink
[CHORE] primitive type으로 교체
Browse files Browse the repository at this point in the history
  • Loading branch information
unanchoi committed Jan 15, 2024
1 parent 44250ce commit 84d6727
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -29,12 +31,14 @@ ResponseEntity<ApplicationCreateResponse> 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<Void> updateApplicationPage1(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public interface UserJpaRepository extends JpaRepository<User, Long> {
Optional<User> findByEmail(String email);

default User findByIdOrThrow(Long id) {
default User findByIdOrThrow(long id) {
return findById(id).orElseThrow(() -> new UnauthorizedException("인증되지 않은 유저입니다."));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("개인정보 수집 및 이용에 동의해주세요.");
}
Expand All @@ -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("해당 지원서의 소유자가 아닙니다.");
Expand Down

0 comments on commit 84d6727

Please sign in to comment.