Skip to content

Commit

Permalink
refactor: 상세작성 Request에 isCurrent 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
shindong96 committed Sep 10, 2024
1 parent 3199936 commit 2ceb5d1
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import gohigher.application.port.in.CompletedUpdatingRequest;
import gohigher.application.port.in.SimpleApplicationProcessRequest;
import gohigher.application.port.in.SimpleApplicationRequest;
import gohigher.application.port.in.SpecificApplicationProcessUpdateRequest;
import gohigher.application.port.in.SpecificApplicationUpdateRequest;
import gohigher.application.port.in.SpecificApplicationProcessRequest;
import gohigher.application.port.in.SpecificApplicationRequest;
import gohigher.common.ProcessType;
import gohigher.user.auth.Provider;
import io.restassured.response.ValidatableResponse;
Expand Down Expand Up @@ -114,13 +114,13 @@ void update_specifically() {
String accessToken = signUp("[email protected]", Provider.GOOGLE);
int applicationId = createApplication(accessToken);

SpecificApplicationUpdateRequest specificApplicationUpdateRequest = new SpecificApplicationUpdateRequest("카카오",
SpecificApplicationRequest specificApplicationRequest = new SpecificApplicationRequest("카카오",
null, null, null, "디자이너", null, null, null, null, null, null, null,
List.of(new SpecificApplicationProcessUpdateRequest("INTERVIEW", "1차 면접", null, true)), null);
List.of(new SpecificApplicationProcessRequest("INTERVIEW", "1차 면접", null, true)), null);

// when
ValidatableResponse response = put(accessToken, "/v1/applications/" + applicationId + "/specific",
specificApplicationUpdateRequest);
specificApplicationRequest);

// then
response.statusCode(HttpStatus.OK.value());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public interface ApplicationCommandPort {

void updateSimply(Long userId, Long applicationId, SimpleApplicationUpdateRequest request);

void updateSpecifically(Long userId, Long applicationId, SpecificApplicationUpdateRequest request);
void updateSpecifically(Long userId, Long applicationId, SpecificApplicationRequest request);

void updateCurrentProcess(Long userId, CurrentProcessUpdateRequest request);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@Getter
public class SpecificApplicationProcessRequest {

@NotBlank(message = "JOB_INFO_005||전형 단계가 입력되지 않았습니다.")
Expand All @@ -18,6 +18,15 @@ public class SpecificApplicationProcessRequest {
private String description;

private LocalDateTime schedule;
private Boolean isCurrent;

public SpecificApplicationProcessRequest(String type, String description, LocalDateTime schedule,
Boolean isCurrent) {
this.type = type;
this.description = description;
this.schedule = schedule;
this.isCurrent = isCurrent;
}

public Process toDomain() {
return new Process(ProcessType.from(type), description, schedule);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package gohigher.application.port.in;

import java.util.ArrayList;
import java.util.List;

import gohigher.application.Application;
Expand All @@ -11,8 +12,8 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
@Getter
public class SpecificApplicationRequest {

@NotBlank(message = "JOB_INFO_002||회사명이 입력되지 않았습니다.")
Expand All @@ -35,14 +36,40 @@ public class SpecificApplicationRequest {
private List<SpecificApplicationProcessRequest> processes;
private String url;

public SpecificApplicationRequest(String companyName, String team, String location, String contact,
String position, String specificPosition, String jobDescription, String workType, String employmentType,
String careerRequirement, String requiredCapability, String preferredQualification,
List<SpecificApplicationProcessRequest> processes, String url) {
this.companyName = companyName;
this.team = team;
this.location = location;
this.contact = contact;
this.position = position;
this.specificPosition = specificPosition;
this.jobDescription = jobDescription;
this.workType = workType;
this.employmentType = employmentType;
this.careerRequirement = careerRequirement;
this.requiredCapability = requiredCapability;
this.preferredQualification = preferredQualification;
this.processes = processes;
this.url = url;
}

public Application toDomain() {
List<Process> processes = this.processes.stream()
.map(SpecificApplicationProcessRequest::toDomain)
.toList();
List<Process> processDomains = new ArrayList<>();
int currentProcessIdx = 0;

for (int i = 0; i < processes.size(); i++) {
if (processes.get(i).getIsCurrent()) {
currentProcessIdx = i;
}
processDomains.add(processes.get(i).toDomain());
}

return Application.specify(null, companyName, team, location, contact, position, specificPosition,
jobDescription,
workType, EmploymentType.from(employmentType), careerRequirement, requiredCapability,
preferredQualification, Processes.initialFrom(processes), url, processes.get(0));
preferredQualification, Processes.initialFrom(processDomains), url, processDomains.get(currentProcessIdx));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import gohigher.application.port.in.SimpleApplicationRequest;
import gohigher.application.port.in.SimpleApplicationUpdateRequest;
import gohigher.application.port.in.SpecificApplicationRequest;
import gohigher.application.port.in.SpecificApplicationUpdateRequest;
import gohigher.application.port.out.persistence.ApplicationPersistenceCommandPort;
import gohigher.application.port.out.persistence.ApplicationPersistenceQueryPort;
import gohigher.application.port.out.persistence.ApplicationProcessPersistenceQueryPort;
Expand Down Expand Up @@ -56,7 +55,7 @@ public void updateSimply(Long userId, Long applicationId, SimpleApplicationUpdat
}

@Override
public void updateSpecifically(Long userId, Long applicationId, SpecificApplicationUpdateRequest request) {
public void updateSpecifically(Long userId, Long applicationId, SpecificApplicationRequest request) {
Application application = applicationPersistenceQueryPort.findByIdAndUserId(applicationId, userId)
.orElseThrow(() -> new GoHigherException(ApplicationErrorCode.APPLICATION_NOT_FOUND));
Application updatedApplication = application.updateSpecifically(request.toDomain());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import gohigher.application.port.in.SimpleApplicationRequest;
import gohigher.application.port.in.SimpleApplicationUpdateRequest;
import gohigher.application.port.in.SpecificApplicationRequest;
import gohigher.application.port.in.SpecificApplicationUpdateRequest;
import gohigher.controller.response.GohigherResponse;
import gohigher.support.auth.Login;
import jakarta.validation.Valid;
Expand Down Expand Up @@ -64,7 +63,7 @@ public ResponseEntity<GohigherResponse<Void>> updateSimply(@Login Long userId, @

@PutMapping("/{applicationId}/specific")
public ResponseEntity<GohigherResponse<Void>> updateSpecifically(@Login Long userId,
@PathVariable Long applicationId, @RequestBody @Valid SpecificApplicationUpdateRequest request) {
@PathVariable Long applicationId, @RequestBody @Valid SpecificApplicationRequest request) {
applicationCommandPort.updateSpecifically(userId, applicationId, request);
return ResponseEntity.ok(GohigherResponse.success(null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import gohigher.application.port.in.SimpleApplicationRequest;
import gohigher.application.port.in.SimpleApplicationUpdateRequest;
import gohigher.application.port.in.SpecificApplicationRequest;
import gohigher.application.port.in.SpecificApplicationUpdateRequest;
import gohigher.controller.response.GohigherResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
Expand Down Expand Up @@ -291,7 +290,7 @@ ResponseEntity<GohigherResponse<Void>> updateSimply(@Parameter(hidden = true) Lo
""")
}))})
ResponseEntity<GohigherResponse<Void>> updateSpecifically(@Parameter(hidden = true) Long userId,
Long applicationId, @RequestBody SpecificApplicationUpdateRequest request);
Long applicationId, @RequestBody SpecificApplicationRequest request);

@Operation(summary = "지원서 완료 여부 변경")
@ApiResponses(
Expand Down

0 comments on commit 2ceb5d1

Please sign in to comment.