Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SL-17 CHORE] user의 지원서 반환 시 null값 정보도 리턴하도록 수정 #45

Merged
merged 7 commits into from
Dec 30, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ public class ApplicationListWithSubmittedResponse {

// member의 작성 application의 List
private List<ApplicationListGetResponse> applicationList;

// null값으로 채워진 ApplicationList
private ApplicationListGetResponse defaultApplicationList;
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,35 @@ public ApplicationListWithSubmittedResponse getApplicationList(Long userId) {
List<Application> 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<ApplicationListGetResponse> applicationList = loadApplicationList(applications);

// null값 지원서
ApplicationListGetResponse defaultApplication = ApplicationListGetResponse.of(null,null,null,null,null);


return new ApplicationListWithSubmittedResponse(isSubmitted, applicationList, defaultApplication);
}

// 제출된 지원서 있는지 체크
private boolean checkIsSubmitted(List<Application> 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<ApplicationListGetResponse> loadApplicationList(List<Application> applications){
List<ApplicationListGetResponse> applicationList = applications.stream()
.map(application -> ApplicationListGetResponse.of(
application.getApplicationId(),
Expand All @@ -38,6 +61,6 @@ public ApplicationListWithSubmittedResponse getApplicationList(Long userId) {
application.getStatus()))
.collect(Collectors.toList());

return new ApplicationListWithSubmittedResponse(isSubmitted, applicationList);
return applicationList;
}
}