PMT-16: Add Mapper for Project Creation/Created DTO to/from Project Entity

Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
This commit is contained in:
Dominik Säume 2024-10-07 15:56:38 +02:00 committed by Git Euph
parent f8c802b187
commit 94700b15b9

View file

@ -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;
}
}