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:
|
qualificationId:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
EmployeeDTO:
|
Employee:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
id:
|
id:
|
||||||
|
@ -100,8 +100,8 @@ components:
|
||||||
skillSet:
|
skillSet:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/QualificationDTO'
|
$ref: '#/components/schemas/Qualification'
|
||||||
QualificationDTO:
|
Qualification:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
skill:
|
skill:
|
||||||
|
@ -109,13 +109,13 @@ components:
|
||||||
id:
|
id:
|
||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
GetEmployeesByProjectDTO:
|
ProjectEmployeesDTO:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
employees:
|
employees:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: "#/components/schemas/EmployeeDTO"
|
$ref: "#/components/schemas/Employee"
|
||||||
responses:
|
responses:
|
||||||
Ok:
|
Ok:
|
||||||
description: "OK"
|
description: "OK"
|
||||||
|
@ -299,7 +299,7 @@ paths:
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/components/schemas/GetEmployeesByProjectDTO"
|
$ref: "#/components/schemas/ProjectEmployeesDTO"
|
||||||
description: 'Get a List of all Employees from a specific Project '
|
description: 'Get a List of all Employees from a specific Project '
|
||||||
404:
|
404:
|
||||||
$ref: '#/components/responses/NotFound'
|
$ref: '#/components/responses/NotFound'
|
||||||
|
|
|
@ -155,12 +155,12 @@ public class ApiController implements DefaultApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<GetEmployeesByProjectDTO> getAListOfAllEmployeesFromASpecificProject(Long id) {
|
public ResponseEntity<ProjectEmployeesDTO> getAListOfAllEmployeesFromASpecificProject(Long id) {
|
||||||
if (!projectRepository.existsById(id)) {
|
if (!projectRepository.existsById(id)) {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
GetEmployeesByProjectDTO dto = new GetEmployeesByProjectDTO();
|
ProjectEmployeesDTO dto = new ProjectEmployeesDTO();
|
||||||
List<Allocation> allocationsByProject = allocationRepository.findAllByProjectId(id);
|
List<Allocation> allocationsByProject = allocationRepository.findAllByProjectId(id);
|
||||||
if (allocationsByProject.isEmpty()) {
|
if (allocationsByProject.isEmpty()) {
|
||||||
return new ResponseEntity<>(dto, HttpStatus.OK);
|
return new ResponseEntity<>(dto, HttpStatus.OK);
|
||||||
|
@ -171,7 +171,7 @@ public class ApiController implements DefaultApi {
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<EmployeeDTO> employees = apiClientFactory.getEmployeeApi().findAll1().stream()
|
List<Employee> employees = apiClientFactory.getEmployeeApi().findAll1().stream()
|
||||||
.filter(employeeResponseDTO -> employeeIds.contains(employeeResponseDTO.getId()))
|
.filter(employeeResponseDTO -> employeeIds.contains(employeeResponseDTO.getId()))
|
||||||
.map(mapper::map)
|
.map(mapper::map)
|
||||||
.toList();
|
.toList();
|
||||||
|
@ -180,8 +180,5 @@ public class ApiController implements DefaultApi {
|
||||||
} catch (RestClientException exception) {
|
} catch (RestClientException exception) {
|
||||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
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.db.Project;
|
||||||
import de.hmmh.pmt.dtos.CreateProjectDTO;
|
import de.hmmh.pmt.dtos.CreateProjectDTO;
|
||||||
import de.hmmh.pmt.dtos.CreatedProjectDTO;
|
import de.hmmh.pmt.dtos.CreatedProjectDTO;
|
||||||
import de.hmmh.pmt.dtos.EmployeeDTO;
|
import de.hmmh.pmt.dtos.Employee;
|
||||||
import de.hmmh.pmt.dtos.QualificationDTO;
|
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 org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -36,8 +36,8 @@ public class Mapper {
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmployeeDTO map(EmployeeResponseDTO employeeResponseDTO) {
|
public Employee map(EmployeeResponseDTO employeeResponseDTO) {
|
||||||
EmployeeDTO dto = new EmployeeDTO();
|
Employee dto = new Employee();
|
||||||
dto.setId(employeeResponseDTO.getId());
|
dto.setId(employeeResponseDTO.getId());
|
||||||
dto.setLastName(employeeResponseDTO.getLastName());
|
dto.setLastName(employeeResponseDTO.getLastName());
|
||||||
dto.setFirstName(employeeResponseDTO.getFirstName());
|
dto.setFirstName(employeeResponseDTO.getFirstName());
|
||||||
|
@ -46,7 +46,7 @@ public class Mapper {
|
||||||
dto.setCity(employeeResponseDTO.getCity());
|
dto.setCity(employeeResponseDTO.getCity());
|
||||||
dto.setPhone(employeeResponseDTO.getPhone());
|
dto.setPhone(employeeResponseDTO.getPhone());
|
||||||
|
|
||||||
List<QualificationDTO> skillSet = employeeResponseDTO.getSkillSet().stream()
|
List<Qualification > skillSet = employeeResponseDTO.getSkillSet().stream()
|
||||||
.map(this::map)
|
.map(this::map)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
|
@ -54,8 +54,8 @@ public class Mapper {
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
private QualificationDTO map(QualificationGetDTO qualificationGetDTO) {
|
private Qualification map(QualificationGetDTO qualificationGetDTO) {
|
||||||
QualificationDTO dto = new QualificationDTO();
|
Qualification dto = new Qualification ();
|
||||||
dto.setId(qualificationGetDTO.getId());
|
dto.setId(qualificationGetDTO.getId());
|
||||||
dto.setSkill(qualificationGetDTO.getSkill());
|
dto.setSkill(qualificationGetDTO.getSkill());
|
||||||
return dto;
|
return dto;
|
||||||
|
|
Loading…
Reference in a new issue