PMT-26 refactor naming pmt.yml, ApiController, Mapper
This commit is contained in:
parent
289cf7e120
commit
a9ae63bf8e
3 changed files with 16 additions and 19 deletions
12
api/pmt.yml
12
api/pmt.yml
|
@ -77,7 +77,7 @@ components:
|
|||
qualificationId:
|
||||
type: integer
|
||||
format: int64
|
||||
EmployeeDTO:
|
||||
Employee:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
|
@ -100,8 +100,8 @@ components:
|
|||
skillSet:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/QualificationDTO'
|
||||
QualificationDTO:
|
||||
$ref: '#/components/schemas/Qualification'
|
||||
Qualification:
|
||||
type: object
|
||||
properties:
|
||||
skill:
|
||||
|
@ -109,13 +109,13 @@ components:
|
|||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
GetEmployeesByProjectDTO:
|
||||
ProjectEmployeesDTO:
|
||||
type: object
|
||||
properties:
|
||||
employees:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/EmployeeDTO"
|
||||
$ref: "#/components/schemas/Employee"
|
||||
responses:
|
||||
Ok:
|
||||
description: "OK"
|
||||
|
@ -299,7 +299,7 @@ paths:
|
|||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/GetEmployeesByProjectDTO"
|
||||
$ref: "#/components/schemas/ProjectEmployeesDTO"
|
||||
description: 'Get a List of all Employees from a specific Project '
|
||||
404:
|
||||
$ref: '#/components/responses/NotFound'
|
||||
|
|
|
@ -155,12 +155,12 @@ public class ApiController implements DefaultApi {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<GetEmployeesByProjectDTO> getAListOfAllEmployeesFromASpecificProject(Long id) {
|
||||
public ResponseEntity<ProjectEmployeesDTO> getAListOfAllEmployeesFromASpecificProject(Long id) {
|
||||
if (!projectRepository.existsById(id)) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
GetEmployeesByProjectDTO dto = new GetEmployeesByProjectDTO();
|
||||
ProjectEmployeesDTO dto = new ProjectEmployeesDTO();
|
||||
List<Allocation> allocationsByProject = allocationRepository.findAllByProjectId(id);
|
||||
if (allocationsByProject.isEmpty()) {
|
||||
return new ResponseEntity<>(dto, HttpStatus.OK);
|
||||
|
@ -171,7 +171,7 @@ public class ApiController implements DefaultApi {
|
|||
.collect(Collectors.toSet());
|
||||
|
||||
try {
|
||||
List<EmployeeDTO> employees = apiClientFactory.getEmployeeApi().findAll1().stream()
|
||||
List<Employee> employees = apiClientFactory.getEmployeeApi().findAll1().stream()
|
||||
.filter(employeeResponseDTO -> employeeIds.contains(employeeResponseDTO.getId()))
|
||||
.map(mapper::map)
|
||||
.toList();
|
||||
|
@ -180,8 +180,5 @@ public class ApiController implements DefaultApi {
|
|||
} catch (RestClientException exception) {
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
// Was wenn, die Liste der Allocation und die Liste der EmployeeResponseDTO nicht die gleiche Anzahl haben.
|
||||
// Das EmployeeResponseDTO wird vom EmployeeService gestellt, sollte man die Daten auf eigenes DTO mappen.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package de.hmmh.pmt.util;
|
|||
import de.hmmh.pmt.db.Project;
|
||||
import de.hmmh.pmt.dtos.CreateProjectDTO;
|
||||
import de.hmmh.pmt.dtos.CreatedProjectDTO;
|
||||
import de.hmmh.pmt.dtos.EmployeeDTO;
|
||||
import de.hmmh.pmt.dtos.QualificationDTO;
|
||||
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.QualificationGetDTO;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -36,8 +36,8 @@ public class Mapper {
|
|||
return dto;
|
||||
}
|
||||
|
||||
public EmployeeDTO map(EmployeeResponseDTO employeeResponseDTO) {
|
||||
EmployeeDTO dto = new EmployeeDTO();
|
||||
public Employee map(EmployeeResponseDTO employeeResponseDTO) {
|
||||
Employee dto = new Employee();
|
||||
dto.setId(employeeResponseDTO.getId());
|
||||
dto.setLastName(employeeResponseDTO.getLastName());
|
||||
dto.setFirstName(employeeResponseDTO.getFirstName());
|
||||
|
@ -46,7 +46,7 @@ public class Mapper {
|
|||
dto.setCity(employeeResponseDTO.getCity());
|
||||
dto.setPhone(employeeResponseDTO.getPhone());
|
||||
|
||||
List<QualificationDTO> skillSet = employeeResponseDTO.getSkillSet().stream()
|
||||
List<Qualification > skillSet = employeeResponseDTO.getSkillSet().stream()
|
||||
.map(this::map)
|
||||
.toList();
|
||||
|
||||
|
@ -54,8 +54,8 @@ public class Mapper {
|
|||
return dto;
|
||||
}
|
||||
|
||||
private QualificationDTO map(QualificationGetDTO qualificationGetDTO) {
|
||||
QualificationDTO dto = new QualificationDTO();
|
||||
private Qualification map(QualificationGetDTO qualificationGetDTO) {
|
||||
Qualification dto = new Qualification ();
|
||||
dto.setId(qualificationGetDTO.getId());
|
||||
dto.setSkill(qualificationGetDTO.getSkill());
|
||||
return dto;
|
||||
|
|
Loading…
Reference in a new issue