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:
parent
1dc4c7c65a
commit
b0f94bcb4b
1 changed files with 32 additions and 0 deletions
32
src/main/java/de/hmmh/pmt/util/Mapper.java
Normal file
32
src/main/java/de/hmmh/pmt/util/Mapper.java
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue