From 6ce0ebd834494fa4a9ad89b41c1a06becf6aa3ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20S=C3=A4ume?= Date: Mon, 7 Oct 2024 15:56:38 +0200 Subject: [PATCH] PMT-16: Add Mapper for Project Creation/Created DTO to/from Project Entity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Dominik Säume --- src/main/java/de/hmmh/pmt/util/Mapper.java | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/de/hmmh/pmt/util/Mapper.java 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; + } +}