diff --git a/src/main/java/com/startlion/startlionserver/dto/response/application/ApplicationListWithSubmittedResponse.java b/src/main/java/com/startlion/startlionserver/dto/response/application/ApplicationListWithSubmittedResponse.java index 0dc1f07..90a956a 100644 --- a/src/main/java/com/startlion/startlionserver/dto/response/application/ApplicationListWithSubmittedResponse.java +++ b/src/main/java/com/startlion/startlionserver/dto/response/application/ApplicationListWithSubmittedResponse.java @@ -13,4 +13,7 @@ public class ApplicationListWithSubmittedResponse { // member의 작성 application의 List private List applicationList; + + // null값으로 채워진 ApplicationList + private ApplicationListGetResponse defaultApplicationList; } diff --git a/src/main/java/com/startlion/startlionserver/service/UserService.java b/src/main/java/com/startlion/startlionserver/service/UserService.java index 0cf1351..7df41f5 100644 --- a/src/main/java/com/startlion/startlionserver/service/UserService.java +++ b/src/main/java/com/startlion/startlionserver/service/UserService.java @@ -23,12 +23,35 @@ public ApplicationListWithSubmittedResponse getApplicationList(Long userId) { List applications = applicationJpaRepository.findByUserUserId(userId); // applications 리스트를 순회하면서 status가 "Y"인 application이 있는지 확인 - boolean isSubmittedExists = applications.stream() - .anyMatch(application -> "Y".equals(application.getStatus())); + boolean isSubmittedExists = checkIsSubmitted(applications); // boolean을 String으로 변환 - String isSubmitted = isSubmittedExists ? "Y" : "N"; + String isSubmitted = boolToString(isSubmittedExists); + + // 지원서 리스트 가져오기 + List applicationList = loadApplicationList(applications); + + // null값 지원서 + ApplicationListGetResponse defaultApplication = ApplicationListGetResponse.of(null,null,null,null,null); + + + return new ApplicationListWithSubmittedResponse(isSubmitted, applicationList, defaultApplication); + } + + // 제출된 지원서 있는지 체크 + private boolean checkIsSubmitted(List applications){ + boolean isSubmitted = applications.stream() + .anyMatch(application -> "Y".equals(application.getStatus())); + return isSubmitted; + } + + // boolean을 String으로 변환 + private String boolToString(boolean bool){ + return bool ? "Y" : "N"; + } + // 지원서 리스트 불러오기 + private List loadApplicationList(List applications){ List applicationList = applications.stream() .map(application -> ApplicationListGetResponse.of( application.getApplicationId(), @@ -38,6 +61,6 @@ public ApplicationListWithSubmittedResponse getApplicationList(Long userId) { application.getStatus())) .collect(Collectors.toList()); - return new ApplicationListWithSubmittedResponse(isSubmitted, applicationList); + return applicationList; } }