From dadea504d06d230b1aa0cb823d40f6f2a0e078cf Mon Sep 17 00:00:00 2001 From: Jose Pabl Domingo Aramburo Sanchez Date: Mon, 6 Aug 2018 15:17:31 -0600 Subject: [PATCH] =?UTF-8?q?[add]=20Em=E1=B9=95loyee=20data=20by=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api-payroll/src/application/EmployeeApplication.php | 10 ++++++++++ api-payroll/src/routes.php | 10 +++++++++- api-payroll/src/settings.php | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/api-payroll/src/application/EmployeeApplication.php b/api-payroll/src/application/EmployeeApplication.php index 5573b9b..5c0fcdc 100644 --- a/api-payroll/src/application/EmployeeApplication.php +++ b/api-payroll/src/application/EmployeeApplication.php @@ -269,6 +269,16 @@ class EmployeeApplication{ return $response; } + /** + * @param $code string + * @return array + */ + function getEmployeeDataByCode($code){ + $idEmployee = $this->getIdEmployeeTypeByCode($code); + + return $this->proxyGetEmployeeDataById($idEmployee); + } + /** * @param $idPerson integer * @param $firstName binary diff --git a/api-payroll/src/routes.php b/api-payroll/src/routes.php index f36b17a..7d28e55 100644 --- a/api-payroll/src/routes.php +++ b/api-payroll/src/routes.php @@ -79,10 +79,18 @@ $app->get('/api/employee/type/{code}', function (Request $request, Response $res ->write(json_encode($this->employeeApplication->getIdEmployeeTypeByCode($code))); }); -$app->get('/api/employee/{idEmployee}', function (Request $request, Response $response, array $args) { +$app->get('/api/employee/id/{idEmployee}', function (Request $request, Response $response, array $args) { $idEmployee = $args['idEmployee']; return $response->withStatus(200) ->withHeader('Content-Type', 'application/json') ->write(json_encode($this->employeeApplication->proxyGetEmployeeDataById($idEmployee))); +}); + +$app->get('/api/employee/code/{code}', function (Request $request, Response $response, array $args) { + $code = $args['code']; + + return $response->withStatus(200) + ->withHeader('Content-Type', 'application/json') + ->write(json_encode($this->employeeApplication->getEmployeeDataByCode($code))); }); \ No newline at end of file diff --git a/api-payroll/src/settings.php b/api-payroll/src/settings.php index 10ea7c9..435f286 100644 --- a/api-payroll/src/settings.php +++ b/api-payroll/src/settings.php @@ -43,7 +43,7 @@ return [ // Employee settings 'employee' => [ - 'codeLength' => '5', + 'codeLength' => '3', ], ], ];