Skip to content

Commit

Permalink
[REFACTOR] Page 4 업데이트 API 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
unanchoi committed Jan 13, 2024
1 parent 4f05e0d commit d008ad2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import lombok.*;
import org.springframework.util.Assert;

import java.util.stream.Collectors;

@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED) @Getter
public class Application extends BaseTimeEntity {
Expand Down Expand Up @@ -94,7 +96,9 @@ public class Application extends BaseTimeEntity {
/*
인터뷰 가능 시간
*/
private String availableInterviewTime;
private String availableInterviewTime1;
private String availableInterviewTime2;
private String availableInterviewTime3;

@Enumerated(EnumType.STRING)
private PathType pathToKnow;
Expand All @@ -120,6 +124,8 @@ public class Application extends BaseTimeEntity {
@Column(columnDefinition = "TEXT")
private String partAnswer4;

private boolean lastCheck = false;

private int commonAnswer1Limit = DEFAULT_ANSWER_LIMIT;
private int commonAnswer2Limit = DEFAULT_ANSWER_LIMIT;
private int commonAnswer3Limit = DEFAULT_ANSWER_LIMIT;
Expand Down Expand Up @@ -222,7 +228,23 @@ public void updateApplicationPage3(ApplicationPage3Request request) {

public void updateApplicationPage4(ApplicationPage4Request request) {
validateSubmitStatus();
this.availableInterviewTime = request.availableInterviewTime();
val availableInterviewTime1 = request.firstDay()
.stream()
.map(Object::toString)
.collect(Collectors.joining(","));

val availableInterviewTime2 = request.secondDay()
.stream()
.map(Object::toString)
.collect(Collectors.joining(","));

val availableInterviewTime3 = request.thirdDay()
.stream()
.map(Object::toString)
.collect(Collectors.joining(","));
this.availableInterviewTime1 = availableInterviewTime1;
this.availableInterviewTime2 = availableInterviewTime2;
this.availableInterviewTime3 = availableInterviewTime3;
}

public void completeApplication() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@

import io.swagger.v3.oas.annotations.media.Schema;

import java.util.List;


@Schema(description = "지원서 페이지 4 요청")
public record ApplicationPage4Request(
@Schema(description = "최종 제출 여부", example = "true")
boolean isSubmit,
@Schema(description = "면접 시간", example = "0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1")
String availableInterviewTime
) {
@Schema(description = "면접 가능 날짜 첫번째", example = "[0,0,0,0,0,0,0,0,0,0]")
List<Integer> firstDay,
@Schema(description = "면접 가능 날짜 두번쨰", example = "[0,0,0,0,0,0,0,0,0,0]")
List<Integer> secondDay,
@Schema(description = "면접 가능 날짜 세번쨰", example = "[0,0,0,0,0,0,0,0,0,0]")
List<Integer> thirdDay

) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public record ApplicationResponse(
String portfolioUrl,
@Schema(description = "지원서 상태")
String status,
@Schema(description = "가능한 인터뷰 시간", example = "0 0 1 0 0 0 1 0 0 1 0 1 0 0 0 1 0 0 1 0 1 0 1 1 1 1")
String availableInterviewTime,
@Schema(description = "공통 질문 1 답변")
String commonAnswer1,
@Schema(description = "공통 질문 2 답변")
Expand Down Expand Up @@ -62,7 +60,6 @@ public static ApplicationResponse of(Application application) {
application.getEmail(),
application.getPortfolioUrl(),
application.getStatus().toString(),
application.getAvailableInterviewTime(),
application.getCommonAnswer1(),
application.getCommonAnswer2(),
application.getCommonAnswer3(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ public ApplicationPage3Response getApplicationPage3(Long applicationId, Long use
public ApplicationPage4Response getApplicationPage4(Long applicationId, Long userId) {
val application = applicationJpaRepository.findByIdOrThrow(applicationId);
checkApplicationOwner(application, userId);
val availableTimes = List.of(application.getAvailableInterviewTime().split(","));
val firstDays = availableTimes.subList(0, FIRST_DAY_LAST_INTERVIEW_INDEX);
val secondDays = availableTimes.subList(FIRST_DAY_LAST_INTERVIEW_INDEX+1, SECOND_DAY_LAST_INTERVIEW_INDEX);
val thirdDays = availableTimes.subList(SECOND_DAY_LAST_INTERVIEW_INDEX+1, availableTimes.size()-1);
val firstDays = List.of(application.getAvailableInterviewTime1().split(","));
val secondDays = List.of(application.getAvailableInterviewTime2().split(","));
val thirdDays = List.of(application.getAvailableInterviewTime3().split(","));
return ApplicationPage4Response.of(firstDays, secondDays, thirdDays);
}

Expand Down

0 comments on commit d008ad2

Please sign in to comment.