Compare commits
35 Commits
updatingEm
...
qualityCha
| Author | SHA1 | Date | |
|---|---|---|---|
| 231e7fe2e6 | |||
| f820a22a4f | |||
| 0cdfd21fa2 | |||
| fee3db486f | |||
| 87181696e1 | |||
| 8b22c0db9c | |||
| 18ee0ad333 | |||
| 4928481f72 | |||
|
|
2d11218076 | ||
| 59a4d6e4a5 | |||
| 7cf083a612 | |||
| d4135188bd | |||
| 6d29ac3f23 | |||
| 0449f202ef | |||
| 23868b60ee | |||
| 8a2d5b2afa | |||
| 7ceb2aad93 | |||
| 3902435690 | |||
| f16e9fe72c | |||
| d2b9163537 | |||
| 403541580d | |||
| 663ea7cc3e | |||
| f93b41f14e | |||
| 24f1ce1ed7 | |||
| b25346e3d5 | |||
| f2237d9209 | |||
| 7fc9ca8c75 | |||
| 97fca1d7d3 | |||
| 058e19a49a | |||
| bffeb6e9f4 | |||
| 9a3e876afe | |||
| dadea504d0 | |||
| 1390427ec0 | |||
| 6c4e42e337 | |||
| f4d1ce1ab7 |
5
api-payroll/.dockerignore
Normal file
5
api-payroll/.dockerignore
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
Dockerfile
|
||||||
|
README.md
|
||||||
|
buildspec.yml
|
||||||
|
CONTRIBUTING.md
|
||||||
|
docker-compose.yml
|
||||||
2
api-payroll/.htaccess
Normal file
2
api-payroll/.htaccess
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Options -Indexes
|
||||||
|
Deny from all
|
||||||
52
api-payroll/Dockerfile
Normal file
52
api-payroll/Dockerfile
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# Stage 1 - the build process
|
||||||
|
FROM composer:1.7.1 as build-deps
|
||||||
|
ENV COMPOSER_ALLOW_SUPERUSER 1
|
||||||
|
|
||||||
|
WORKDIR /root
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN composer install
|
||||||
|
RUN composer test
|
||||||
|
|
||||||
|
# Stage 2 - the production environment
|
||||||
|
FROM ubuntu:16.04
|
||||||
|
|
||||||
|
RUN apt-get -y update && apt-get -y upgrade
|
||||||
|
|
||||||
|
RUN apt-get -y install apache2 \
|
||||||
|
php7.0 \
|
||||||
|
libapache2-mod-php7.0 \
|
||||||
|
php7.0-cli \
|
||||||
|
php7.0-common \
|
||||||
|
php7.0-mbstring \
|
||||||
|
php7.0-gd \
|
||||||
|
php7.0-intl \
|
||||||
|
php7.0-xml \
|
||||||
|
php7.0-mysql \
|
||||||
|
php7.0-mcrypt
|
||||||
|
|
||||||
|
# Enable apache mods
|
||||||
|
RUN a2enmod php7.0
|
||||||
|
RUN a2enmod rewrite
|
||||||
|
|
||||||
|
# Update the PHP.ini file, enable <? ?> tags and quieten logging
|
||||||
|
RUN sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php/7.0/apache2/php.ini
|
||||||
|
RUN sed -i "s/error_reporting = .*$/error_reporting = E_ERROR | E_WARNING | E_PARSE/" /etc/php/7.0/apache2/php.ini
|
||||||
|
|
||||||
|
# Manually set up the apache environment variables
|
||||||
|
ENV APACHE_RUN_USER www-data
|
||||||
|
ENV APACHE_RUN_GROUP www-data
|
||||||
|
ENV APACHE_LOG_DIR /var/log/apache2
|
||||||
|
ENV APACHE_LOCK_DIR /var/lock/apache2
|
||||||
|
|
||||||
|
WORKDIR /var/www/site
|
||||||
|
COPY --from=build-deps /root .
|
||||||
|
|
||||||
|
RUN touch logs/app.log
|
||||||
|
RUN chmod 777 logs/app.log
|
||||||
|
|
||||||
|
# Update the default apache site
|
||||||
|
ADD docker/apache-config.conf /etc/apache2/sites-enabled/000-default.conf
|
||||||
|
|
||||||
|
# By default start up apache in the foreground
|
||||||
|
CMD /usr/sbin/apache2ctl -D FOREGROUND
|
||||||
@@ -14,8 +14,9 @@ phases:
|
|||||||
- echo Entered the build phase...
|
- echo Entered the build phase...
|
||||||
- echo Build started on `date`
|
- echo Build started on `date`
|
||||||
- composer test
|
- composer test
|
||||||
|
- sudo docker-compose up --build -d
|
||||||
post_build:
|
post_build:
|
||||||
commands:
|
commands:
|
||||||
- echo Entered the post_build phase...
|
- echo Entered the post_build phase...
|
||||||
|
- sudo docker-compose down --rmi all -v
|
||||||
- echo Build completed on `date`
|
- echo Build completed on `date`
|
||||||
|
|
||||||
|
|||||||
15
api-payroll/docker/apache-config.conf
Normal file
15
api-payroll/docker/apache-config.conf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<VirtualHost *:80>
|
||||||
|
ServerAdmin me@mydomain.com
|
||||||
|
DocumentRoot /var/www/site
|
||||||
|
|
||||||
|
<Directory /var/www/site/>
|
||||||
|
Options Indexes FollowSymLinks MultiViews
|
||||||
|
AllowOverride All
|
||||||
|
Order deny,allow
|
||||||
|
Allow from all
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||||
|
CustomLog ${APACHE_LOG_DIR}/access.log combined
|
||||||
|
|
||||||
|
</VirtualHost>
|
||||||
0
api-payroll/logs/app.log
Executable file
0
api-payroll/logs/app.log
Executable file
@@ -1,3 +1,5 @@
|
|||||||
|
allow from all
|
||||||
|
|
||||||
<IfModule mod_rewrite.c>
|
<IfModule mod_rewrite.c>
|
||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
|
|
||||||
|
|||||||
6
api-payroll/public/css/bootstrap.min.css
vendored
Normal file
6
api-payroll/public/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
81
api-payroll/public/css/login.css
Normal file
81
api-payroll/public/css/login.css
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
body {
|
||||||
|
background: url(../imagenes/grey_background.jpg);
|
||||||
|
background-size: cover;
|
||||||
|
font-family: Montserrat;
|
||||||
|
}
|
||||||
|
@media only screen and (min-device-width: 480px) {
|
||||||
|
body {
|
||||||
|
background: url('../imagenes/grey_background.jpg') no-repeat fixed center center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.logo {
|
||||||
|
width: 213px;
|
||||||
|
height: 60px;
|
||||||
|
margin: 30px auto;
|
||||||
|
}
|
||||||
|
.login-block {
|
||||||
|
width: 320px;
|
||||||
|
padding: 20px;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 5px;
|
||||||
|
border-top: 5px solid #bdb035;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
.login-block h1 {
|
||||||
|
text-align: center;
|
||||||
|
color: #000;
|
||||||
|
font-size: 18px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.login-block input {
|
||||||
|
width: 100%;
|
||||||
|
height: 42px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-radius: 5px;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-family: Montserrat;
|
||||||
|
padding: 0 20px 0 50px;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
.login-block input#user {
|
||||||
|
background: #fff url('../imagenes/login_username.png') 20px top no-repeat;
|
||||||
|
background-size: 16px 80px;
|
||||||
|
}
|
||||||
|
.login-block input#user:focus {
|
||||||
|
background: #fff url('../imagenes/login_username.png') 20px bottom no-repeat;
|
||||||
|
background-size: 16px 80px;
|
||||||
|
}
|
||||||
|
.login-block input#password {
|
||||||
|
background: #fff url('../imagenes/login_password.png') 20px top no-repeat;
|
||||||
|
background-size: 16px 80px;
|
||||||
|
}
|
||||||
|
.login-block input#password:focus {
|
||||||
|
background: #fff url('../imagenes/login_password.png') 20px bottom no-repeat;
|
||||||
|
background-size: 16px 80px;
|
||||||
|
}
|
||||||
|
.login-block input:active, .login-block input:focus {
|
||||||
|
border: 1px solid #bdb035;
|
||||||
|
}
|
||||||
|
.login-block #loginButon {
|
||||||
|
width: 100%;
|
||||||
|
height: 40px;
|
||||||
|
background: #bdb035;
|
||||||
|
box-sizing: border-box;
|
||||||
|
border-radius: 5px;
|
||||||
|
border: 1px solid #6d661c;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: bold;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 14px;
|
||||||
|
font-family: Montserrat;
|
||||||
|
outline: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.login-block button:hover {
|
||||||
|
background: #c7b935;
|
||||||
|
border: 1px solid #6d661c;
|
||||||
|
}
|
||||||
44
api-payroll/public/html/login.php
Normal file
44
api-payroll/public/html/login.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<!-- Latest compiled and minified CSS -->
|
||||||
|
<link rel="stylesheet" href="../css/bootstrap.min.css">
|
||||||
|
|
||||||
|
<!-- jQuery library -->
|
||||||
|
<script src="../js/jquery.min.js"></script>
|
||||||
|
|
||||||
|
<!-- Latest compiled JavaScript -->
|
||||||
|
<script src="../js/bootstrap.min.js"></script>
|
||||||
|
|
||||||
|
<link href='http://fonts.googleapis.com/css?family=Montserrat:400,700' rel='stylesheet' type='text/css'>
|
||||||
|
<div class="container">
|
||||||
|
<div class="logo"></div>
|
||||||
|
<div class="login-block">
|
||||||
|
<form action="" method="post" name="Login_Form" class="login">
|
||||||
|
<h1>Login</h1>
|
||||||
|
<input type="text" value="" placeholder="User" id="userName" name="user" required="" autofocus=""/>
|
||||||
|
<input type="password" value="" placeholder="Password" id="password" name="password" required=""/>
|
||||||
|
<a href="#" class="btn btn-lg btn-warning btn-default" id="loginButon" name="login" value="Login" onclick="processLogin();">Login</a>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="modalLoginError" class="modal fade" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
|
||||||
|
<!-- Modal content-->
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header" id="modalLoginErrorHeader">
|
||||||
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
|
<h4 class="modal-title"><center>Ha ocurrido un error</center></h4>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p id="modalLoginErrorBody"></p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-default" data-dismiss="modal">Cerrar</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="../js/login.js"></script>
|
||||||
|
<link href="../css/login.css" rel="stylesheet">
|
||||||
BIN
api-payroll/public/imagenes/grey_background.jpg
Normal file
BIN
api-payroll/public/imagenes/grey_background.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 33 KiB |
BIN
api-payroll/public/imagenes/login_password.png
Normal file
BIN
api-payroll/public/imagenes/login_password.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
BIN
api-payroll/public/imagenes/login_username.png
Normal file
BIN
api-payroll/public/imagenes/login_username.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
7
api-payroll/public/js/bootstrap.min.js
vendored
Normal file
7
api-payroll/public/js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
api-payroll/public/js/jquery.min.js
vendored
Normal file
2
api-payroll/public/js/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
38
api-payroll/public/js/login.js
Normal file
38
api-payroll/public/js/login.js
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
function getbaseUrl(uriPath){
|
||||||
|
var url = window.location.href;
|
||||||
|
return url.substring(0, url.indexOf(uriPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
function processLogin() {
|
||||||
|
console.log(getbaseUrl('html/'));
|
||||||
|
var parametros = {
|
||||||
|
"userName":$('#userName').val(),
|
||||||
|
"password":$('#password').val()
|
||||||
|
};
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: getbaseUrl('/html/') + '/index.php/api/session/login',
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
data: parametros,
|
||||||
|
success:function(data){
|
||||||
|
console.log(JSON.stringify(data));
|
||||||
|
if(data["status"] == "success"){
|
||||||
|
redirect("http://stackoverflow.com");
|
||||||
|
}else if(data["status"] == "success" || (data["status"] === undefined)){
|
||||||
|
$('#modalLoginError').modal('show');
|
||||||
|
document.getElementById('modalLoginErrorBody').innerHTML = "The server didn't respond in time, please try again or refresh this page.";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error:function(x) {
|
||||||
|
if (x.status==500){
|
||||||
|
$('#modalLoginError').modal('show');
|
||||||
|
document.getElementById('modalLoginErrorBody').innerHTML = "The user or password didnt match, please try again";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function redirect(url){
|
||||||
|
window.location.replace(url);
|
||||||
|
}
|
||||||
@@ -38,7 +38,12 @@ class EmployeeApplication{
|
|||||||
}
|
}
|
||||||
$stmt = null;
|
$stmt = null;
|
||||||
|
|
||||||
return $results;
|
$employeeTypes = array();
|
||||||
|
foreach($results as $row){
|
||||||
|
$employeeTypes[] = array('id' => (int)$row['id'], 'name' => $row['name']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $employeeTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -269,6 +274,16 @@ class EmployeeApplication{
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $code string
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function getEmployeeDataByCode($code){
|
||||||
|
$idEmployee = $this->getIdEmployeeTypeByCode($code);
|
||||||
|
|
||||||
|
return $this->proxyGetEmployeeDataById($idEmployee);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $idPerson integer
|
* @param $idPerson integer
|
||||||
* @param $firstName binary
|
* @param $firstName binary
|
||||||
@@ -404,5 +419,44 @@ class EmployeeApplication{
|
|||||||
$this->pdo->rollback();
|
$this->pdo->rollback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Intended for internal use
|
||||||
|
*
|
||||||
|
* This method will bring a list of ids of all the employees that are
|
||||||
|
* currently active in the system
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function getIdEmployeeFromAllActiveEmployees(){
|
||||||
|
$stmt = $this->pdo->prepare("SELECT
|
||||||
|
id
|
||||||
|
FROM
|
||||||
|
employees
|
||||||
|
WHERE
|
||||||
|
status = 'ACTIVE';");
|
||||||
|
$stmt->execute();
|
||||||
|
|
||||||
|
$results = $stmt->fetchAll();
|
||||||
|
|
||||||
|
if(!$results){
|
||||||
|
exit($this->databaseSelectQueryErrorMessage);
|
||||||
|
}
|
||||||
|
$stmt = null;
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
|
function listAllActiveEmployees(){
|
||||||
|
$ids = $this->getIdEmployeeFromAllActiveEmployees();
|
||||||
|
|
||||||
|
$result = array();
|
||||||
|
|
||||||
|
foreach($ids as $row){
|
||||||
|
$result[] = $this->proxyGetEmployeeDataById($row['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@@ -69,7 +69,7 @@ class SessionApplication{
|
|||||||
|
|
||||||
// If the credentials don't match anything in the the records
|
// If the credentials don't match anything in the the records
|
||||||
if(!isset($storedPassword)){
|
if(!isset($storedPassword)){
|
||||||
throw new Exception('The user or password didnt match, please try again.');
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Already has a session
|
// Already has a session
|
||||||
@@ -82,7 +82,22 @@ class SessionApplication{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return false;
|
throw new Exception('The user or password didnt match, please try again.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $userName
|
||||||
|
* @param $password
|
||||||
|
* @return array
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
function login($userName, $password){
|
||||||
|
if($this->newSession($userName, $password)){
|
||||||
|
return array('status' => 'success', 'message' => 'Logged in successfully.');
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
throw new Exception('The user or password didnt match, please try again.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ $container['mysql'] = function ($c) {
|
|||||||
|
|
||||||
// The database parameters
|
// The database parameters
|
||||||
$host = $mysqlSettings['host'];
|
$host = $mysqlSettings['host'];
|
||||||
|
$port = $mysqlSettings['port'];
|
||||||
$database = $mysqlSettings['database'];
|
$database = $mysqlSettings['database'];
|
||||||
$user = $mysqlSettings['user'];
|
$user = $mysqlSettings['user'];
|
||||||
$password = $mysqlSettings['password'];
|
$password = $mysqlSettings['password'];
|
||||||
@@ -34,7 +35,7 @@ $container['mysql'] = function ($c) {
|
|||||||
$databaseConnectionErrorMessage = $mysqlSettings['databaseConnectionErrorMessage'];
|
$databaseConnectionErrorMessage = $mysqlSettings['databaseConnectionErrorMessage'];
|
||||||
|
|
||||||
// Initiate the connection
|
// Initiate the connection
|
||||||
$dsn = "mysql:host=$host;dbname=$database;charset=$charset";
|
$dsn = "mysql:host=$host;port=$port;dbname=$database;charset=$charset";
|
||||||
try {
|
try {
|
||||||
$pdo = new PDO($dsn, $user, $password, $pdoConnectionOptions);
|
$pdo = new PDO($dsn, $user, $password, $pdoConnectionOptions);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@@ -69,4 +70,4 @@ $container['employeeApplication'] = function ($c) {
|
|||||||
$employeeApplication = new App\Application\EmployeeApplication($employeeSettings,
|
$employeeApplication = new App\Application\EmployeeApplication($employeeSettings,
|
||||||
$c['mysql'], $c['cryptographyService'], $c['asserts']);
|
$c['mysql'], $c['cryptographyService'], $c['asserts']);
|
||||||
return $employeeApplication;
|
return $employeeApplication;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,14 +22,14 @@ $app->get('/api/session', function (Request $request, Response $response, array
|
|||||||
$app->post('/api/session/login', function ($request, $response) {
|
$app->post('/api/session/login', function ($request, $response) {
|
||||||
$requestData = $request->getParsedBody();
|
$requestData = $request->getParsedBody();
|
||||||
|
|
||||||
$data = $this->sessionApplication->newSession($requestData['userName'], $requestData['password']);
|
$data = $this->sessionApplication->login($requestData['userName'], $requestData['password']);
|
||||||
|
|
||||||
return $response->withStatus(200)
|
return $response->withStatus(200)
|
||||||
->withHeader('Content-Type', 'application/json')
|
->withHeader('Content-Type', 'application/json')
|
||||||
->write(json_encode($data));
|
->write(json_encode($data));
|
||||||
});
|
});
|
||||||
|
|
||||||
$app->post('/api/session/logout', function (Request $request, Response $response, array $args) {
|
$app->get('/api/session/logout', function (Request $request, Response $response, array $args) {
|
||||||
return $response->withStatus(200)
|
return $response->withStatus(200)
|
||||||
->withHeader('Content-Type', 'application/json')
|
->withHeader('Content-Type', 'application/json')
|
||||||
->write(json_encode($this->sessionApplication->destroySession()));
|
->write(json_encode($this->sessionApplication->destroySession()));
|
||||||
@@ -41,6 +41,12 @@ $app->get('/api/employee/types', function (Request $request, Response $response,
|
|||||||
->write(json_encode($this->employeeApplication->listEmployeeTypes()));
|
->write(json_encode($this->employeeApplication->listEmployeeTypes()));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$app->get('/api/employee/all', function (Request $request, Response $response, array $args) {
|
||||||
|
return $response->withStatus(200)
|
||||||
|
->withHeader('Content-Type', 'application/json')
|
||||||
|
->write(json_encode($this->employeeApplication->listAllActiveEmployees()));
|
||||||
|
});
|
||||||
|
|
||||||
$app->post('/api/employee', function ($request, $response) {
|
$app->post('/api/employee', function ($request, $response) {
|
||||||
$requestData = $request->getParsedBody();
|
$requestData = $request->getParsedBody();
|
||||||
|
|
||||||
@@ -73,10 +79,18 @@ $app->get('/api/employee/type/{code}', function (Request $request, Response $res
|
|||||||
->write(json_encode($this->employeeApplication->getIdEmployeeTypeByCode($code)));
|
->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'];
|
$idEmployee = $args['idEmployee'];
|
||||||
|
|
||||||
return $response->withStatus(200)
|
return $response->withStatus(200)
|
||||||
->withHeader('Content-Type', 'application/json')
|
->withHeader('Content-Type', 'application/json')
|
||||||
->write(json_encode($this->employeeApplication->proxyGetEmployeeDataById($idEmployee)));
|
->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)));
|
||||||
});
|
});
|
||||||
@@ -26,7 +26,8 @@ return [
|
|||||||
|
|
||||||
// Datanase settings
|
// Datanase settings
|
||||||
'mysql' => [
|
'mysql' => [
|
||||||
'host' => 'localhost',
|
'host' => 'mysql',
|
||||||
|
'port' => '3307',
|
||||||
'database' => 'payroll',
|
'database' => 'payroll',
|
||||||
'user' => 'root',
|
'user' => 'root',
|
||||||
'password' => '12345678',
|
'password' => '12345678',
|
||||||
@@ -43,7 +44,7 @@ return [
|
|||||||
|
|
||||||
// Employee settings
|
// Employee settings
|
||||||
'employee' => [
|
'employee' => [
|
||||||
'codeLength' => '5',
|
'codeLength' => '3',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
1
database/.dockerignore
Normal file
1
database/.dockerignore
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Dockerfile
|
||||||
7
database/Dockerfile
Normal file
7
database/Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
FROM mysql:5.7
|
||||||
|
|
||||||
|
# Starting scripts
|
||||||
|
ADD . /docker-entrypoint-initdb.d
|
||||||
|
|
||||||
|
# Config
|
||||||
|
ADD my.cnf /etc/mysql
|
||||||
20
database/my.cnf
Normal file
20
database/my.cnf
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; version 2 of the License.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software
|
||||||
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
[mysqld]
|
||||||
|
port = 3307
|
||||||
|
|
||||||
|
!includedir /etc/mysql/conf.d/
|
||||||
|
!includedir /etc/mysql/mysql.conf.d/
|
||||||
28
docker-compose.yml
Normal file
28
docker-compose.yml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
version: '3'
|
||||||
|
services:
|
||||||
|
api:
|
||||||
|
container_name: payroll_api
|
||||||
|
build: api-payroll/
|
||||||
|
ports:
|
||||||
|
- "8085:80"
|
||||||
|
volumes:
|
||||||
|
- ./volumes/apache-logs:/var/log/apache2
|
||||||
|
depends_on:
|
||||||
|
- mysql
|
||||||
|
mysql:
|
||||||
|
container_name: payroll_mysql
|
||||||
|
restart: always
|
||||||
|
build: database
|
||||||
|
expose:
|
||||||
|
- "3307"
|
||||||
|
ports:
|
||||||
|
- "3307:3307"
|
||||||
|
volumes:
|
||||||
|
- ./volumes/mysql-data:/var/lib/mysql
|
||||||
|
environment:
|
||||||
|
MYSQL_ROOT_PASSWORD: '12345678'
|
||||||
|
MYSQL_USER: 'sloth'
|
||||||
|
MYSQL_PASS: '12345678'
|
||||||
|
volumes:
|
||||||
|
mysql-data:
|
||||||
|
apache-logs:
|
||||||
2
volumes/.gitignore
vendored
Normal file
2
volumes/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
mysql-data/
|
||||||
|
apache-logs/
|
||||||
1
volumes/README.md
Normal file
1
volumes/README.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# Do not delete this directory, it'll contain the volumes created by the containers
|
||||||
Reference in New Issue
Block a user