Compare commits
5 commits
096c25e33b
...
33157758c3
Author | SHA1 | Date | |
---|---|---|---|
|
33157758c3 | ||
|
54725d7fb1 | ||
|
ada6f9c90f | ||
|
f0b7317d49 | ||
|
32b81b5d41 |
3 changed files with 91 additions and 0 deletions
54
api/pmt.yml
54
api/pmt.yml
|
@ -87,6 +87,31 @@ components:
|
|||
plannedEnd:
|
||||
type: string
|
||||
format: date-time
|
||||
Project:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
name:
|
||||
type: string
|
||||
goal:
|
||||
type: string
|
||||
customerId:
|
||||
type: integer
|
||||
format: int64
|
||||
administratorId:
|
||||
type: integer
|
||||
format: int64
|
||||
start:
|
||||
type: string
|
||||
format: date-time
|
||||
plannedEnd:
|
||||
type: string
|
||||
format: date-time
|
||||
realEnd:
|
||||
type: string
|
||||
format: date-time
|
||||
AddEmployeeDTO:
|
||||
type: object
|
||||
properties:
|
||||
|
@ -135,6 +160,13 @@ components:
|
|||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Employee"
|
||||
EmployeeProjectsDTO:
|
||||
type: object
|
||||
properties:
|
||||
projects:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Project'
|
||||
responses:
|
||||
Unauthorized:
|
||||
description: "Unauthorized"
|
||||
|
@ -366,3 +398,25 @@ paths:
|
|||
$ref: '#/components/responses/NotFound'
|
||||
500:
|
||||
$ref: "#/components/responses/InternalError"
|
||||
/employye/{id}/projects:
|
||||
get:
|
||||
description: "getAllProjects"
|
||||
operationId: "Get a List of all Projects from a specific Employee"
|
||||
parameters:
|
||||
- in: path
|
||||
name: id
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
required: true
|
||||
responses:
|
||||
200:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/EmployeeProjectsDTO"
|
||||
description: 'Get a List of all Projects from a specific Employee'
|
||||
404:
|
||||
$ref: '#/components/responses/NotFound'
|
||||
500:
|
||||
$ref: '#/components/responses/InternalError'
|
||||
|
|
|
@ -3,6 +3,7 @@ package de.hmmh.pmt;
|
|||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import de.hmmh.pmt.db.*;
|
||||
import de.hmmh.pmt.db.Project;
|
||||
import de.hmmh.pmt.dtos.*;
|
||||
import de.hmmh.pmt.employee.ApiClientFactory;
|
||||
import de.hmmh.pmt.employee.dtos.EmployeeResponseDTO;
|
||||
|
@ -225,4 +226,28 @@ public class ApiController implements DefaultApi {
|
|||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<EmployeeProjectsDTO> getAListOfAllProjectsFromASpecificEmployee(Long id) {
|
||||
if (!projectRepository.existsById(id)) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
EmployeeProjectsDTO dto = new EmployeeProjectsDTO();
|
||||
List<Allocation> allocationsByEmployee = allocationRepository.findAllByEmployeeId(id);
|
||||
if (allocationsByEmployee.isEmpty()) {
|
||||
return new ResponseEntity<>(dto, HttpStatus.OK);
|
||||
}
|
||||
|
||||
Set<Project> projects = allocationsByEmployee.stream()
|
||||
.map(Allocation::getProject)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
EmployeeProjectsDTO response = new EmployeeProjectsDTO();
|
||||
|
||||
for (Project project : projects) {
|
||||
response.addProjectsItem(mapper.mapProject(project));
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,4 +72,16 @@ public class Mapper {
|
|||
project.setPlannedEnd(dto.getPlannedEnd());
|
||||
return project;
|
||||
}
|
||||
public de.hmmh.pmt.dtos.Project mapProject(Project project){
|
||||
de.hmmh.pmt.dtos.Project dto = new de.hmmh.pmt.dtos.Project();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue