diff --git a/src/main/java/de/hmmh/pmt/util/Mapper.java b/src/main/java/de/hmmh/pmt/util/Mapper.java new file mode 100644 index 0000000..d5d7591 --- /dev/null +++ b/src/main/java/de/hmmh/pmt/util/Mapper.java @@ -0,0 +1,32 @@ +package de.hmmh.pmt.util; + +import de.hmmh.pmt.db.Project; +import de.hmmh.pmt.dtos.CreateProjectDTO; +import de.hmmh.pmt.dtos.CreatedProjectDTO; +import org.springframework.stereotype.Component; + +@Component +public class Mapper { + public Project map(CreateProjectDTO dto) { + Project project = new Project(); + project.setName(dto.getName()); + project.setGoal(dto.getGoal()); + project.setCustomerId(dto.getCustomerId()); + project.setAdministratorId(dto.getAdministratorId()); + project.setStart(dto.getStart()); + project.setPlannedEnd(dto.getPlannedEnd()); + return project; + } + + public CreatedProjectDTO map(Project project) { + CreatedProjectDTO dto = new CreatedProjectDTO(); + dto.setId(project.getId()); + dto.setName(project.getName()); + dto.setGoal(project.getGoal()); + dto.setCustomerId(project.getCustomerId()); + dto.setAdministratorId(project.getAdministratorId()); + dto.setStart(project.getStart()); + dto.setPlannedEnd(project.getPlannedEnd()); + return dto; + } +}