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

refactor: Component 도메인 converter 상속 제거 #305

Merged
merged 5 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,28 @@
@RequestMapping("/api/v1/resumes")
public class ComponentController {

private final ComponentService blockService;
private final ComponentService componentService;

@PostMapping("/{resumeId}/{type}")
public IdResponse createComponent(@PathVariable Long resumeId, @RequestBody ComponentCreateRequest request, @PathVariable Property type) {
return new IdResponse(blockService.create(request.toEntity().toComponent(resumeId), type));
return new IdResponse(componentService.create(request.toVo().toComponent(resumeId), type));
}

@GetMapping({"/{resumeId}", "/{resumeId}/{type}"})
public AllComponentResponse getComponent(@PathVariable Long resumeId, @PathVariable(required = false) Property type) {
ResumeTemplate template = blockService.getAll(resumeId, type);
ResumeTemplate template = componentService.getAll(resumeId, type);

return AllComponentResponse.from(template);
}

@PatchMapping("/{resumeId}/{type}/components/{componentId}")
public IdResponse updateComponent(@PathVariable Long resumeId, @PathVariable Property type, @RequestBody ComponentCreateRequest request, @PathVariable Long componentId) {
return new IdResponse(blockService.update(componentId, request.toEntity().toComponent(resumeId), type));
return new IdResponse(componentService.update(componentId, request.toVo().toComponent(resumeId), type));
}

@DeleteMapping("/{resumeId}/components/{componentId}")
public void deleteComponent(@PathVariable Long componentId) {
blockService.delete(componentId);
componentService.delete(componentId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.devcourse.resumeme.business.resume.controller.dto.ComponentCreateRequest;
import org.devcourse.resumeme.business.resume.domain.career.Career;
import org.devcourse.resumeme.business.resume.domain.career.Duty;
import org.devcourse.resumeme.business.resume.service.vo.CareerDomainVo;

import java.time.LocalDate;
import java.util.ArrayList;
Expand Down Expand Up @@ -54,12 +55,14 @@ public CareerCreateRequest(
}

@Override
public Career toEntity() {
public CareerDomainVo toVo() {
List<Duty> duties = this.duties.stream()
.map(DutyRequest::toEntity)
.toList();

return new Career(companyName, position, skills, duties, careerStartDate, endDate, careerContent);
Career career = new Career(companyName, position, skills, duties, careerStartDate, endDate, careerContent);

return new CareerDomainVo(career);
}

public record DutyRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import lombok.Getter;
import lombok.NoArgsConstructor;
import org.devcourse.resumeme.business.resume.domain.Converter;
import org.devcourse.resumeme.business.resume.domain.career.Career;
import org.devcourse.resumeme.business.resume.domain.career.Duty;

Expand Down Expand Up @@ -31,9 +30,8 @@ public class CareerResponse extends ComponentResponse {

private String careerContent;

public CareerResponse(Converter converter) {
super(converter);
Career career = (Career) converter;
public CareerResponse(Career career) {
super(career.getComponentInfo());
this.companyName = career.getCompanyName();
this.position = career.getPosition();
this.skills = career.getSkills();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import lombok.Getter;
import lombok.NoArgsConstructor;
import org.devcourse.resumeme.business.resume.domain.Converter;
import org.devcourse.resumeme.business.resume.domain.ComponentInfo;

import static lombok.AccessLevel.PROTECTED;

Expand All @@ -18,10 +18,10 @@ public abstract class ComponentResponse {
@Getter
protected boolean reflectFeedback;

protected ComponentResponse(Converter converter) {
this.componentId = converter.getComponentId();
this.originComponentId = converter.getOriginComponentId();
this.reflectFeedback = converter.isReflectFeedback();
protected ComponentResponse(ComponentInfo info) {
this.componentId = info.getComponentId();
this.originComponentId = info.getOriginComponentId();
this.reflectFeedback = info.isReflectFeedback();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.Setter;
import org.devcourse.resumeme.business.resume.controller.dto.ComponentCreateRequest;
import org.devcourse.resumeme.business.resume.domain.Certification;
import org.devcourse.resumeme.business.resume.service.vo.CertificationDomainVo;

@Getter @Setter
@NoArgsConstructor
Expand Down Expand Up @@ -37,8 +38,10 @@ public CertificationCreateRequest(
}

@Override
public Certification toEntity() {
return new Certification(certificationTitle, acquisitionDate, issuingAuthority, link, description);
public CertificationDomainVo toVo() {
Certification certification = new Certification(certificationTitle, acquisitionDate, issuingAuthority, link, description);

return new CertificationDomainVo(certification);
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.devcourse.resumeme.business.resume.controller.dto;

import com.fasterxml.jackson.annotation.JsonTypeName;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.devcourse.resumeme.business.resume.domain.Activity;
import org.devcourse.resumeme.business.resume.service.vo.ActivityDomainVo;

import java.time.LocalDate;

Expand Down Expand Up @@ -43,8 +43,10 @@ public ActivityCreateRequest(
}

@Override
public Activity toEntity() {
return new Activity(activityName, startDate, endDate, link, description);
public ActivityDomainVo toVo() {
Activity activity = new Activity(activityName, startDate, endDate, link, description);

return new ActivityDomainVo(activity);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import lombok.NoArgsConstructor;
import org.devcourse.resumeme.business.resume.controller.career.dto.ComponentResponse;
import org.devcourse.resumeme.business.resume.domain.Activity;
import org.devcourse.resumeme.business.resume.domain.Converter;

import java.time.LocalDate;

Expand All @@ -26,9 +25,8 @@ public class ActivityResponse extends ComponentResponse {

private String description;

public ActivityResponse(Converter converter) {
super(converter);
Activity activity = (Activity) converter;
public ActivityResponse(Activity activity) {
super(activity.getComponentInfo());
this.activityName = activity.getActivityName();
this.startDate = activity.getStartDate();
this.endDate = activity.getEndDate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import lombok.NoArgsConstructor;
import org.devcourse.resumeme.business.resume.controller.career.dto.ComponentResponse;
import org.devcourse.resumeme.business.resume.domain.Certification;
import org.devcourse.resumeme.business.resume.domain.Converter;

import static lombok.AccessLevel.PRIVATE;

Expand All @@ -22,9 +21,8 @@ public class CertificationResponse extends ComponentResponse {

private String description;

public CertificationResponse(Converter converter) {
super(converter);
Certification certification = (Certification) converter;
public CertificationResponse(Certification certification) {
super(certification.getComponentInfo());
this.certificationTitle = certification.getCertificationTitle();
this.acquisitionDate = certification.getAcquisitionDate();
this.issuingAuthority = certification.getIssuingAuthority();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.devcourse.resumeme.business.resume.controller.career.dto.CareerCreateRequest;
import org.devcourse.resumeme.business.resume.controller.certification.dto.CertificationCreateRequest;
import org.devcourse.resumeme.business.resume.domain.Converter;
import org.devcourse.resumeme.business.resume.service.v2.ComponentDomain;

@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
Expand All @@ -22,6 +22,6 @@
})
public abstract class ComponentCreateRequest {

public abstract Converter toEntity();
public abstract ComponentDomain toVo();

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.devcourse.resumeme.business.resume.domain.ForeignLanguage;
import org.devcourse.resumeme.business.resume.service.vo.ForeignLanguageDomainVo;

@Getter @Setter
@NoArgsConstructor
Expand All @@ -28,8 +29,10 @@ public ForeignLanguageCreateRequest(
}

@Override
public ForeignLanguage toEntity() {
return new ForeignLanguage(language, examName, scoreOrGrade);
public ForeignLanguageDomainVo toVo() {
ForeignLanguage foreignLanguage = new ForeignLanguage(language, examName, scoreOrGrade);

return new ForeignLanguageDomainVo(foreignLanguage);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.devcourse.resumeme.business.resume.controller.career.dto.ComponentResponse;
import org.devcourse.resumeme.business.resume.domain.Converter;
import org.devcourse.resumeme.business.resume.domain.ForeignLanguage;

import static lombok.AccessLevel.PRIVATE;
Expand All @@ -18,9 +17,8 @@ public class ForeignLanguageResponse extends ComponentResponse {

private String scoreOrGrade;

public ForeignLanguageResponse(Converter converter) {
super(converter);
ForeignLanguage foreignLanguage = (ForeignLanguage) converter;
public ForeignLanguageResponse(ForeignLanguage foreignLanguage) {
super(foreignLanguage.getComponentInfo());
this.language = foreignLanguage.getLanguage();
this.examName = foreignLanguage.getExamName();
this.scoreOrGrade = foreignLanguage.getScoreOrGrade();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.devcourse.resumeme.business.resume.domain.Project;
import org.devcourse.resumeme.business.resume.service.vo.ProjectDomainVo;

import java.util.List;

Expand Down Expand Up @@ -46,12 +47,14 @@ public ProjectCreateRequest(
}

@Override
public Project toEntity() {
public ProjectDomainVo toVo() {
if (teamMembers == null) {
teamMembers = "";
}

return new Project(projectName, productionYear, teamMembers, skills, projectContent, projectUrl);
Project project = new Project(projectName, productionYear, teamMembers, skills, projectContent, projectUrl);

return new ProjectDomainVo(project);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.devcourse.resumeme.business.resume.controller.career.dto.ComponentResponse;
import org.devcourse.resumeme.business.resume.domain.Converter;
import org.devcourse.resumeme.business.resume.domain.Project;

import java.util.List;
Expand All @@ -28,9 +27,8 @@ public class ProjectResponse extends ComponentResponse {

private String projectUrl;

public ProjectResponse(Converter converter) {
super(converter);
Project project = (Project) converter;
public ProjectResponse(Project project) {
super(project.getComponentInfo());
this.projectName = project.getProjectName();
this.productionYear = project.getProductionYear();
this.team = !project.getTeamMembers().equals("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.Setter;
import org.devcourse.resumeme.business.resume.domain.LinkType;
import org.devcourse.resumeme.business.resume.domain.ReferenceLink;
import org.devcourse.resumeme.business.resume.service.vo.ReferenceLinkDomainVo;

@Getter @Setter
@NoArgsConstructor
Expand All @@ -21,8 +22,10 @@ public ResumeLinkRequest(String linkType, String url) {
this.url = url;
}

public ReferenceLink toEntity() {
return new ReferenceLink(LinkType.valueOf(linkType), url);
public ReferenceLinkDomainVo toVo() {
ReferenceLink referenceLink = new ReferenceLink(LinkType.valueOf(linkType), url);

return new ReferenceLinkDomainVo(referenceLink);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.devcourse.resumeme.business.resume.controller.career.dto.ComponentResponse;
import org.devcourse.resumeme.business.resume.domain.Converter;
import org.devcourse.resumeme.business.resume.domain.ReferenceLink;

import static lombok.AccessLevel.PRIVATE;
Expand All @@ -16,9 +15,8 @@ public class ResumeLinkResponse extends ComponentResponse {

private String url;

public ResumeLinkResponse(Converter converter) {
super(converter);
ReferenceLink referenceLink = (ReferenceLink) converter;
public ResumeLinkResponse(ReferenceLink referenceLink) {
super(referenceLink.getComponentInfo());
this.linkType = referenceLink.getLinkType().name();
this.url = referenceLink.getAddress();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.devcourse.resumeme.business.resume.domain.Training;
import org.devcourse.resumeme.business.resume.service.vo.TrainingDomainVo;

import java.time.LocalDate;

Expand Down Expand Up @@ -50,8 +51,10 @@ public TrainingCreateRequest(
}

@Override
public Training toEntity() {
return new Training(organization, major, degree, admissionDate, graduationDate, gpa, maxGpa, explanation);
public TrainingDomainVo toVo() {
Training training = new Training(organization, major, degree, admissionDate, graduationDate, gpa, maxGpa, explanation);

return new TrainingDomainVo(training);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.devcourse.resumeme.business.resume.controller.career.dto.ComponentResponse;
import org.devcourse.resumeme.business.resume.domain.Converter;
import org.devcourse.resumeme.business.resume.domain.Training;

import java.time.LocalDate;
Expand All @@ -30,9 +29,8 @@ public class TrainingResponse extends ComponentResponse {

private String explanation;

public TrainingResponse(Converter converter) {
super(converter);
Training training = (Training) converter;
public TrainingResponse(Training training) {
super(training.getComponentInfo());
this.organization = training.getEducationalDetails().getOrganization();
this.major = training.getEducationalDetails().getMajor();
this.degree = training.getEducationalDetails().getDegree();
Expand Down
Loading