Skip to content

Commit

Permalink
refac: application question get api response 변경 #73 (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
wjdtkdgns authored Jul 1, 2023
1 parent 28918e1 commit b68cb58
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ceos.backend.domain.application.dto.response;

import ceos.backend.domain.application.vo.InterviewDateTimesVo;
import ceos.backend.domain.application.vo.QuestionVo;
import ceos.backend.domain.application.vo.QuestionWithIdVo;
import lombok.Builder;
Expand All @@ -14,12 +15,12 @@ public class GetApplicationQuestion {
private List<QuestionWithIdVo> designQuestions;
private List<QuestionWithIdVo> frontendQuestions;
private List<QuestionWithIdVo> backendQuestions;
private List<String> times;
private List<InterviewDateTimesVo> times;

@Builder
private GetApplicationQuestion(List<QuestionWithIdVo> commonQuestions, List<QuestionWithIdVo> productQuestions,
List<QuestionWithIdVo> designQuestions, List<QuestionWithIdVo> frontendQuestions,
List<QuestionWithIdVo> backendQuestions, List<String> times) {
List<QuestionWithIdVo> backendQuestions, List<InterviewDateTimesVo> times) {
this.commonQuestions = commonQuestions;
this.productQuestions = productQuestions;
this.designQuestions = designQuestions;
Expand All @@ -30,7 +31,7 @@ private GetApplicationQuestion(List<QuestionWithIdVo> commonQuestions, List<Ques

public static GetApplicationQuestion of(List<QuestionWithIdVo> commonQuestions, List<QuestionWithIdVo> productQuestions,
List<QuestionWithIdVo> designQuestions, List<QuestionWithIdVo> frontendQuestions,
List<QuestionWithIdVo> backendQuestions, List<String> times) {
List<QuestionWithIdVo> backendQuestions, List<InterviewDateTimesVo> times) {
return GetApplicationQuestion.builder()
.commonQuestions(commonQuestions)
.productQuestions(productQuestions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

@Component
public class ApplicationMapper {
Expand Down Expand Up @@ -152,11 +154,23 @@ public GetApplicationQuestion toGetApplicationQuestion(List<ApplicationQuestion>
}
});

final List<String> times = interviews.stream()
final List<ParsedDuration> parsedDurations = interviews.stream()
.map(InterviewDateFormatter::interviewDateFormatter)
.map(ParsingDuration::parsingDuration)
.toList();
final Set<String> dateSets = parsedDurations.stream()
.map(ParsedDuration::getDate)
.collect(Collectors.toSet());
final List<InterviewDateTimesVo> interviewDateTimesVos = dateSets.stream()
.map(dateSet -> InterviewDateTimesVo.of(dateSet,
parsedDurations.stream()
.filter(parsedDuration -> parsedDuration.getDate().equals(dateSet))
.map(ParsedDuration::getDuration)
.toList())
).toList();

return GetApplicationQuestion.of(commonQuestions, productQuestions, designQuestions,
frontendQuestions, backendQuestions, times);
frontendQuestions, backendQuestions, interviewDateTimesVos);
}

public GetApplication toGetApplication(Application application, List<Interview> interviews,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package ceos.backend.domain.application.vo;

import lombok.Builder;
import lombok.Getter;

import java.util.List;

@Getter
public class InterviewDateTimesVo {
private String date;
private List<String> durations;

@Builder
private InterviewDateTimesVo(String date, List<String> durations) {
this.date = date;
this.durations = durations;
}

public static InterviewDateTimesVo of(String date, List<String> durations) {
return InterviewDateTimesVo.builder()
.date(date)
.durations(durations)
.build();
}
}

0 comments on commit b68cb58

Please sign in to comment.