Skip to content

Commit

Permalink
🔨 #270 update controller e api
Browse files Browse the repository at this point in the history
  • Loading branch information
bjverde committed Sep 28, 2022
1 parent 0b62bce commit 9ac2158
Show file tree
Hide file tree
Showing 31 changed files with 276 additions and 130 deletions.
13 changes: 9 additions & 4 deletions appexemplo_v2.0/api/api_controllers/Acesso_menuAPI.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Download SysGen: https://github.com/bjverde/sysgen
* Download Formdin Framework: https://github.com/bjverde/formDin
*
* SysGen Version: 1.11.0
* SysGen Version: 1.12.0
* FormDin Version: 4.19.0
*
* System appev2 created in: 2022-09-27 15:40:16
* System appev2 created in: 2022-09-28 00:42:11
*/

namespace api_controllers;
Expand Down Expand Up @@ -38,7 +38,9 @@ public static function selectAll(Request $request, Response $response, array $ar
$result = \ArrayHelper::convertArrayFormDin2Pdo($result);
$msg = array( 'qtd_total'=> $qtd_total
, 'qtd_result'=> \CountHelper::count($result)
, 'result'=>$result
, 'page'=>$page
, 'pages'=>$page
, 'result'=>round($qtd_total/$rowsPerPage)
);
$response = TGenericAPI::getBodyJson($msg,$response,200);
return $response;
Expand Down Expand Up @@ -85,7 +87,10 @@ public static function save(Request $request, Response $response, array $args)
if($request->getMethod() == 'PUT'){
$msg = \Message::GENERIC_UPDATE;
$result = self::selectByIdInside($args);
$bodyRequest = $result[0];
$bodyRequest = \ArrayHelper::get($result,0);
if( empty($bodyRequest) ){
throw new \DomainException(\Message::GENERIC_ID_NOT_EXIST);
}
$vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo);
}
$bodyRequest = json_decode($request->getBody(),true);
Expand Down
13 changes: 9 additions & 4 deletions appexemplo_v2.0/api/api_controllers/Acesso_perfilAPI.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Download SysGen: https://github.com/bjverde/sysgen
* Download Formdin Framework: https://github.com/bjverde/formDin
*
* SysGen Version: 1.11.0
* SysGen Version: 1.12.0
* FormDin Version: 4.19.0
*
* System appev2 created in: 2022-09-27 15:40:16
* System appev2 created in: 2022-09-28 00:42:11
*/

namespace api_controllers;
Expand Down Expand Up @@ -38,7 +38,9 @@ public static function selectAll(Request $request, Response $response, array $ar
$result = \ArrayHelper::convertArrayFormDin2Pdo($result);
$msg = array( 'qtd_total'=> $qtd_total
, 'qtd_result'=> \CountHelper::count($result)
, 'result'=>$result
, 'page'=>$page
, 'pages'=>$page
, 'result'=>round($qtd_total/$rowsPerPage)
);
$response = TGenericAPI::getBodyJson($msg,$response,200);
return $response;
Expand Down Expand Up @@ -85,7 +87,10 @@ public static function save(Request $request, Response $response, array $args)
if($request->getMethod() == 'PUT'){
$msg = \Message::GENERIC_UPDATE;
$result = self::selectByIdInside($args);
$bodyRequest = $result[0];
$bodyRequest = \ArrayHelper::get($result,0);
if( empty($bodyRequest) ){
throw new \DomainException(\Message::GENERIC_ID_NOT_EXIST);
}
$vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo);
}
$bodyRequest = json_decode($request->getBody(),true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Download SysGen: https://github.com/bjverde/sysgen
* Download Formdin Framework: https://github.com/bjverde/formDin
*
* SysGen Version: 1.11.0
* SysGen Version: 1.12.0
* FormDin Version: 4.19.0
*
* System appev2 created in: 2022-09-27 15:40:16
* System appev2 created in: 2022-09-28 00:42:12
*/

namespace api_controllers;
Expand Down Expand Up @@ -38,7 +38,9 @@ public static function selectAll(Request $request, Response $response, array $ar
$result = \ArrayHelper::convertArrayFormDin2Pdo($result);
$msg = array( 'qtd_total'=> $qtd_total
, 'qtd_result'=> \CountHelper::count($result)
, 'result'=>$result
, 'page'=>$page
, 'pages'=>$page
, 'result'=>round($qtd_total/$rowsPerPage)
);
$response = TGenericAPI::getBodyJson($msg,$response,200);
return $response;
Expand Down Expand Up @@ -85,7 +87,10 @@ public static function save(Request $request, Response $response, array $args)
if($request->getMethod() == 'PUT'){
$msg = \Message::GENERIC_UPDATE;
$result = self::selectByIdInside($args);
$bodyRequest = $result[0];
$bodyRequest = \ArrayHelper::get($result,0);
if( empty($bodyRequest) ){
throw new \DomainException(\Message::GENERIC_ID_NOT_EXIST);
}
$vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo);
}
$bodyRequest = json_decode($request->getBody(),true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Download SysGen: https://github.com/bjverde/sysgen
* Download Formdin Framework: https://github.com/bjverde/formDin
*
* SysGen Version: 1.11.0
* SysGen Version: 1.12.0
* FormDin Version: 4.19.0
*
* System appev2 created in: 2022-09-27 15:40:16
* System appev2 created in: 2022-09-28 00:42:12
*/

namespace api_controllers;
Expand Down Expand Up @@ -38,7 +38,9 @@ public static function selectAll(Request $request, Response $response, array $ar
$result = \ArrayHelper::convertArrayFormDin2Pdo($result);
$msg = array( 'qtd_total'=> $qtd_total
, 'qtd_result'=> \CountHelper::count($result)
, 'result'=>$result
, 'page'=>$page
, 'pages'=>$page
, 'result'=>round($qtd_total/$rowsPerPage)
);
$response = TGenericAPI::getBodyJson($msg,$response,200);
return $response;
Expand Down Expand Up @@ -85,7 +87,10 @@ public static function save(Request $request, Response $response, array $args)
if($request->getMethod() == 'PUT'){
$msg = \Message::GENERIC_UPDATE;
$result = self::selectByIdInside($args);
$bodyRequest = $result[0];
$bodyRequest = \ArrayHelper::get($result,0);
if( empty($bodyRequest) ){
throw new \DomainException(\Message::GENERIC_ID_NOT_EXIST);
}
$vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo);
}
$bodyRequest = json_decode($request->getBody(),true);
Expand Down
13 changes: 9 additions & 4 deletions appexemplo_v2.0/api/api_controllers/Acesso_userAPI.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Download SysGen: https://github.com/bjverde/sysgen
* Download Formdin Framework: https://github.com/bjverde/formDin
*
* SysGen Version: 1.11.0
* SysGen Version: 1.12.0
* FormDin Version: 4.19.0
*
* System appev2 created in: 2022-09-27 15:40:16
* System appev2 created in: 2022-09-28 00:42:12
*/

namespace api_controllers;
Expand Down Expand Up @@ -38,7 +38,9 @@ public static function selectAll(Request $request, Response $response, array $ar
$result = \ArrayHelper::convertArrayFormDin2Pdo($result);
$msg = array( 'qtd_total'=> $qtd_total
, 'qtd_result'=> \CountHelper::count($result)
, 'result'=>$result
, 'page'=>$page
, 'pages'=>$page
, 'result'=>round($qtd_total/$rowsPerPage)
);
$response = TGenericAPI::getBodyJson($msg,$response,200);
return $response;
Expand Down Expand Up @@ -85,7 +87,10 @@ public static function save(Request $request, Response $response, array $args)
if($request->getMethod() == 'PUT'){
$msg = \Message::GENERIC_UPDATE;
$result = self::selectByIdInside($args);
$bodyRequest = $result[0];
$bodyRequest = \ArrayHelper::get($result,0);
if( empty($bodyRequest) ){
throw new \DomainException(\Message::GENERIC_ID_NOT_EXIST);
}
$vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo);
}
$bodyRequest = json_decode($request->getBody(),true);
Expand Down
15 changes: 11 additions & 4 deletions appexemplo_v2.0/api/api_controllers/Authentication.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ class Authentication
private $urlChamada = null;
private $listPath = array();
private $listPathIgnore= array();
private $listUsers = array();

public function __construct($urlChamada)
{
$this->urlChamada = $urlChamada;
$this->listPathIgnore[] = $urlChamada.'api';
$this->listPathIgnore[] = $urlChamada.'sysinfo';
$this->listUsers['root']= 'teste123';
}

public function getUrlbase(){
Expand All @@ -35,7 +37,14 @@ public function addPath($path){

public function getArrayPathIgnore(){
return $this->listPathIgnore;
}
}

public function addUsers(string $login, string $password){
$this->listUsers[$login] = $password;
}
public function getListUsers(){
return $this->listUsers;
}

/**
* Cria um autenticação basica
Expand All @@ -50,9 +59,7 @@ public function basicAuth(): HttpBasicAuthentication
return new HttpBasicAuthentication([
'ignore'=> $this->getArrayPathIgnore()
,'path' => $this->getArrayPath()
,"users" => [
"root" => "teste123"
]
,"users" => $this->getListUsers()
]);
}
}
13 changes: 9 additions & 4 deletions appexemplo_v2.0/api/api_controllers/AutoridadeAPI.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Download SysGen: https://github.com/bjverde/sysgen
* Download Formdin Framework: https://github.com/bjverde/formDin
*
* SysGen Version: 1.11.0
* SysGen Version: 1.12.0
* FormDin Version: 4.19.0
*
* System appev2 created in: 2022-09-27 15:40:16
* System appev2 created in: 2022-09-28 00:42:12
*/

namespace api_controllers;
Expand Down Expand Up @@ -38,7 +38,9 @@ public static function selectAll(Request $request, Response $response, array $ar
$result = \ArrayHelper::convertArrayFormDin2Pdo($result);
$msg = array( 'qtd_total'=> $qtd_total
, 'qtd_result'=> \CountHelper::count($result)
, 'result'=>$result
, 'page'=>$page
, 'pages'=>$page
, 'result'=>round($qtd_total/$rowsPerPage)
);
$response = TGenericAPI::getBodyJson($msg,$response,200);
return $response;
Expand Down Expand Up @@ -85,7 +87,10 @@ public static function save(Request $request, Response $response, array $args)
if($request->getMethod() == 'PUT'){
$msg = \Message::GENERIC_UPDATE;
$result = self::selectByIdInside($args);
$bodyRequest = $result[0];
$bodyRequest = \ArrayHelper::get($result,0);
if( empty($bodyRequest) ){
throw new \DomainException(\Message::GENERIC_ID_NOT_EXIST);
}
$vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo);
}
$bodyRequest = json_decode($request->getBody(),true);
Expand Down
13 changes: 9 additions & 4 deletions appexemplo_v2.0/api/api_controllers/EnderecoAPI.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Download SysGen: https://github.com/bjverde/sysgen
* Download Formdin Framework: https://github.com/bjverde/formDin
*
* SysGen Version: 1.11.0
* SysGen Version: 1.12.0
* FormDin Version: 4.19.0
*
* System appev2 created in: 2022-09-27 15:40:17
* System appev2 created in: 2022-09-28 00:42:12
*/

namespace api_controllers;
Expand Down Expand Up @@ -38,7 +38,9 @@ public static function selectAll(Request $request, Response $response, array $ar
$result = \ArrayHelper::convertArrayFormDin2Pdo($result);
$msg = array( 'qtd_total'=> $qtd_total
, 'qtd_result'=> \CountHelper::count($result)
, 'result'=>$result
, 'page'=>$page
, 'pages'=>$page
, 'result'=>round($qtd_total/$rowsPerPage)
);
$response = TGenericAPI::getBodyJson($msg,$response,200);
return $response;
Expand Down Expand Up @@ -85,7 +87,10 @@ public static function save(Request $request, Response $response, array $args)
if($request->getMethod() == 'PUT'){
$msg = \Message::GENERIC_UPDATE;
$result = self::selectByIdInside($args);
$bodyRequest = $result[0];
$bodyRequest = \ArrayHelper::get($result,0);
if( empty($bodyRequest) ){
throw new \DomainException(\Message::GENERIC_ID_NOT_EXIST);
}
$vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo);
}
$bodyRequest = json_decode($request->getBody(),true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Download SysGen: https://github.com/bjverde/sysgen
* Download Formdin Framework: https://github.com/bjverde/formDin
*
* SysGen Version: 1.11.0
* SysGen Version: 1.12.0
* FormDin Version: 4.19.0
*
* System appev2 created in: 2022-09-27 15:40:17
* System appev2 created in: 2022-09-28 00:42:12
*/

namespace api_controllers;
Expand Down Expand Up @@ -38,7 +38,9 @@ public static function selectAll(Request $request, Response $response, array $ar
$result = \ArrayHelper::convertArrayFormDin2Pdo($result);
$msg = array( 'qtd_total'=> $qtd_total
, 'qtd_result'=> \CountHelper::count($result)
, 'result'=>$result
, 'page'=>$page
, 'pages'=>$page
, 'result'=>round($qtd_total/$rowsPerPage)
);
$response = TGenericAPI::getBodyJson($msg,$response,200);
return $response;
Expand Down Expand Up @@ -85,7 +87,10 @@ public static function save(Request $request, Response $response, array $args)
if($request->getMethod() == 'PUT'){
$msg = \Message::GENERIC_UPDATE;
$result = self::selectByIdInside($args);
$bodyRequest = $result[0];
$bodyRequest = \ArrayHelper::get($result,0);
if( empty($bodyRequest) ){
throw new \DomainException(\Message::GENERIC_ID_NOT_EXIST);
}
$vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo);
}
$bodyRequest = json_decode($request->getBody(),true);
Expand Down
13 changes: 9 additions & 4 deletions appexemplo_v2.0/api/api_controllers/PedidoAPI.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Download SysGen: https://github.com/bjverde/sysgen
* Download Formdin Framework: https://github.com/bjverde/formDin
*
* SysGen Version: 1.11.0
* SysGen Version: 1.12.0
* FormDin Version: 4.19.0
*
* System appev2 created in: 2022-09-27 15:40:17
* System appev2 created in: 2022-09-28 00:42:12
*/

namespace api_controllers;
Expand Down Expand Up @@ -38,7 +38,9 @@ public static function selectAll(Request $request, Response $response, array $ar
$result = \ArrayHelper::convertArrayFormDin2Pdo($result);
$msg = array( 'qtd_total'=> $qtd_total
, 'qtd_result'=> \CountHelper::count($result)
, 'result'=>$result
, 'page'=>$page
, 'pages'=>$page
, 'result'=>round($qtd_total/$rowsPerPage)
);
$response = TGenericAPI::getBodyJson($msg,$response,200);
return $response;
Expand Down Expand Up @@ -85,7 +87,10 @@ public static function save(Request $request, Response $response, array $args)
if($request->getMethod() == 'PUT'){
$msg = \Message::GENERIC_UPDATE;
$result = self::selectByIdInside($args);
$bodyRequest = $result[0];
$bodyRequest = \ArrayHelper::get($result,0);
if( empty($bodyRequest) ){
throw new \DomainException(\Message::GENERIC_ID_NOT_EXIST);
}
$vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo);
}
$bodyRequest = json_decode($request->getBody(),true);
Expand Down
Loading

0 comments on commit 9ac2158

Please sign in to comment.