PMT-37: implement Endpoint
This commit is contained in:
parent
ce038dc725
commit
3dd06fbf0c
2 changed files with 27 additions and 5 deletions
|
@ -72,6 +72,18 @@ public class ApiController implements DefaultApi {
|
||||||
return ResponseEntity.ok(response);
|
return ResponseEntity.ok(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<GetAllProjectInfoDTO> getProjectInfo(Long id){
|
||||||
|
Optional<Project> optionalProject = projectRepository.findById(id);
|
||||||
|
if (optionalProject.isEmpty()) {
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
Project project = optionalProject.get();
|
||||||
|
|
||||||
|
return ResponseEntity.ok(mapper.mapToGet(project));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Void> updateProject(Long id, UpdateProjectDTO body) {
|
public ResponseEntity<Void> updateProject(Long id, UpdateProjectDTO body) {
|
||||||
Optional<Project> optionalProject = projectRepository.findById(id);
|
Optional<Project> optionalProject = projectRepository.findById(id);
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
package de.hmmh.pmt.util;
|
package de.hmmh.pmt.util;
|
||||||
|
|
||||||
import de.hmmh.pmt.db.Project;
|
import de.hmmh.pmt.db.Project;
|
||||||
import de.hmmh.pmt.dtos.CreateProjectDTO;
|
import de.hmmh.pmt.dtos.*;
|
||||||
import de.hmmh.pmt.dtos.CreatedProjectDTO;
|
|
||||||
import de.hmmh.pmt.dtos.Employee;
|
|
||||||
import de.hmmh.pmt.dtos.Qualification ;
|
|
||||||
import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO;
|
import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO;
|
||||||
import de.hmmh.pmt.employee.dtos.QualificationGetDTO;
|
import de.hmmh.pmt.employee.dtos.QualificationGetDTO;
|
||||||
import de.hmmh.pmt.dtos.UpdateProjectDTO;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -37,6 +34,19 @@ public class Mapper {
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public GetAllProjectInfoDTO mapToGet(Project project) {
|
||||||
|
GetAllProjectInfoDTO dto = new GetAllProjectInfoDTO();
|
||||||
|
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());
|
||||||
|
dto.setRealEnd(project.getRealEnd());
|
||||||
|
return dto;
|
||||||
|
}
|
||||||
|
|
||||||
public Employee map(EmployeeResponseDTO employeeResponseDTO) {
|
public Employee map(EmployeeResponseDTO employeeResponseDTO) {
|
||||||
Employee dto = new Employee();
|
Employee dto = new Employee();
|
||||||
dto.setId(employeeResponseDTO.getId());
|
dto.setId(employeeResponseDTO.getId());
|
||||||
|
|
Loading…
Reference in a new issue