[add] Returning employee data by id
This commit is contained in:
parent
30420975c4
commit
666b17c0dc
@ -175,9 +175,15 @@ class EmployeeApplication{
|
|||||||
return $results[0]['id'];
|
return $results[0]['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the data associated with the employee
|
||||||
|
*
|
||||||
|
* @param $idEmployee
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
function getEmployeeDataById($idEmployee){
|
function getEmployeeDataById($idEmployee){
|
||||||
$stmt = $this->pdo->prepare("SELECT
|
$stmt = $this->pdo->prepare("SELECT
|
||||||
p.id,
|
p.id AS idPerson,
|
||||||
p.firstName,
|
p.firstName,
|
||||||
p.middleName,
|
p.middleName,
|
||||||
IFNULL(p.lastName, '') AS lastName,
|
IFNULL(p.lastName, '') AS lastName,
|
||||||
@ -201,5 +207,31 @@ class EmployeeApplication{
|
|||||||
|
|
||||||
return $results[0];
|
return $results[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acts as a man in the middle for the getEmployeeDataById method to decrypt the contents
|
||||||
|
* and make the necesary data manipulations
|
||||||
|
*
|
||||||
|
* @param $idEmployee
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function proxyGetEmployeeDataById($idEmployee){
|
||||||
|
$employeeData = $this->getEmployeeDataById($idEmployee);
|
||||||
|
|
||||||
|
$response = array(
|
||||||
|
"idPerson" => (int)$employeeData['idPerson'],
|
||||||
|
"firstName" => $this->cryptographyService->decryptString($employeeData['firstName']),
|
||||||
|
"middleName" => $this->cryptographyService->decryptString($employeeData['middleName']),
|
||||||
|
"lastName" => $this->cryptographyService->decryptString($employeeData['lastName']),
|
||||||
|
"email" => $this->cryptographyService->decryptString($employeeData['email']),
|
||||||
|
"phone" => $employeeData['phone'],
|
||||||
|
"code" => $employeeData['code'],
|
||||||
|
"contractType" => $employeeData['contractType']
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -62,5 +62,5 @@ $app->get('/api/employee/{idEmployee}', function (Request $request, Response $re
|
|||||||
|
|
||||||
return $response->withStatus(200)
|
return $response->withStatus(200)
|
||||||
->withHeader('Content-Type', 'application/json')
|
->withHeader('Content-Type', 'application/json')
|
||||||
->write(json_encode($this->employeeApplication->getEmployeeDataById($idEmployee)));
|
->write(json_encode($this->employeeApplication->proxyGetEmployeeDataById($idEmployee)));
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user