From 9ac2158d09995fafc2dac8ea86472cf2269b867d Mon Sep 17 00:00:00 2001 From: Bjverde Date: Wed, 28 Sep 2022 01:12:17 -0300 Subject: [PATCH] :hammer: #270 update controller e api --- .../api_controllers/Acesso_menuAPI.class.php | 13 +++++++--- .../Acesso_perfilAPI.class.php | 13 +++++++--- .../Acesso_perfil_menuAPI.class.php | 13 +++++++--- .../Acesso_perfil_userAPI.class.php | 13 +++++++--- .../api_controllers/Acesso_userAPI.class.php | 13 +++++++--- .../api_controllers/Authentication.class.php | 15 ++++++++--- .../api_controllers/AutoridadeAPI.class.php | 13 +++++++--- .../api/api_controllers/EnderecoAPI.class.php | 13 +++++++--- .../Natureza_juridicaAPI.class.php | 13 +++++++--- .../api/api_controllers/PedidoAPI.class.php | 13 +++++++--- .../api_controllers/Pedido_itemAPI.class.php | 13 +++++++--- .../api/api_controllers/PessoaAPI.class.php | 13 +++++++--- .../Pessoa_fisicaAPI.class.php | 13 +++++++--- .../Pessoa_juridicaAPI.class.php | 13 +++++++--- .../api/api_controllers/ProdutoAPI.class.php | 13 +++++++--- .../api/api_controllers/RegiaoAPI.class.php | 13 +++++++--- .../SelfilhosmenuAPI.class.php | 8 +++--- .../SelfilhosmenuqtdAPI.class.php | 8 +++--- .../api/api_controllers/TGenericAPI.class.php | 18 ++++++------- .../api/api_controllers/TelefoneAPI.class.php | 13 +++++++--- .../api/api_controllers/TipoAPI.class.php | 13 +++++++--- .../api/api_controllers/UfAPI.class.php | 13 +++++++--- .../Vw_acesso_user_menuAPI.class.php | 8 +++--- .../api_controllers/Vw_pessoaAPI.class.php | 8 +++--- .../Vw_pessoa_fisicaAPI.class.php | 8 +++--- .../Vw_pessoa_marca_produtoAPI.class.php | 8 +++--- .../Vw_regiao_municipioAPI.class.php | 8 +++--- .../controllers/Acesso_menu.class.php | 19 +++++++++++--- .../controllers/Acesso_perfil.class.php | 26 ++++++++++--------- .../controllers/Acesso_perfil_menu.class.php | 17 +++++++++--- .../controllers/Acesso_perfil_user.class.php | 21 +++++++++++---- 31 files changed, 276 insertions(+), 130 deletions(-) diff --git a/appexemplo_v2.0/api/api_controllers/Acesso_menuAPI.class.php b/appexemplo_v2.0/api/api_controllers/Acesso_menuAPI.class.php index 19b8a0cf..fd87ddc1 100644 --- a/appexemplo_v2.0/api/api_controllers/Acesso_menuAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/Acesso_menuAPI.class.php @@ -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; @@ -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; @@ -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); diff --git a/appexemplo_v2.0/api/api_controllers/Acesso_perfilAPI.class.php b/appexemplo_v2.0/api/api_controllers/Acesso_perfilAPI.class.php index 7e2421c6..92eda26b 100644 --- a/appexemplo_v2.0/api/api_controllers/Acesso_perfilAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/Acesso_perfilAPI.class.php @@ -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; @@ -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; @@ -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); diff --git a/appexemplo_v2.0/api/api_controllers/Acesso_perfil_menuAPI.class.php b/appexemplo_v2.0/api/api_controllers/Acesso_perfil_menuAPI.class.php index 07937a1c..97227f68 100644 --- a/appexemplo_v2.0/api/api_controllers/Acesso_perfil_menuAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/Acesso_perfil_menuAPI.class.php @@ -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; @@ -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; @@ -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); diff --git a/appexemplo_v2.0/api/api_controllers/Acesso_perfil_userAPI.class.php b/appexemplo_v2.0/api/api_controllers/Acesso_perfil_userAPI.class.php index cebd6693..f9a8af6c 100644 --- a/appexemplo_v2.0/api/api_controllers/Acesso_perfil_userAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/Acesso_perfil_userAPI.class.php @@ -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; @@ -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; @@ -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); diff --git a/appexemplo_v2.0/api/api_controllers/Acesso_userAPI.class.php b/appexemplo_v2.0/api/api_controllers/Acesso_userAPI.class.php index b75e9a3d..81fd5a8e 100644 --- a/appexemplo_v2.0/api/api_controllers/Acesso_userAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/Acesso_userAPI.class.php @@ -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; @@ -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; @@ -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); diff --git a/appexemplo_v2.0/api/api_controllers/Authentication.class.php b/appexemplo_v2.0/api/api_controllers/Authentication.class.php index 93c70331..4eb721c5 100644 --- a/appexemplo_v2.0/api/api_controllers/Authentication.class.php +++ b/appexemplo_v2.0/api/api_controllers/Authentication.class.php @@ -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(){ @@ -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 @@ -50,9 +59,7 @@ public function basicAuth(): HttpBasicAuthentication return new HttpBasicAuthentication([ 'ignore'=> $this->getArrayPathIgnore() ,'path' => $this->getArrayPath() - ,"users" => [ - "root" => "teste123" - ] + ,"users" => $this->getListUsers() ]); } } \ No newline at end of file diff --git a/appexemplo_v2.0/api/api_controllers/AutoridadeAPI.class.php b/appexemplo_v2.0/api/api_controllers/AutoridadeAPI.class.php index c4cfb063..cba9b2b8 100644 --- a/appexemplo_v2.0/api/api_controllers/AutoridadeAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/AutoridadeAPI.class.php @@ -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; @@ -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; @@ -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); diff --git a/appexemplo_v2.0/api/api_controllers/EnderecoAPI.class.php b/appexemplo_v2.0/api/api_controllers/EnderecoAPI.class.php index 7c77eec1..2cea6821 100644 --- a/appexemplo_v2.0/api/api_controllers/EnderecoAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/EnderecoAPI.class.php @@ -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; @@ -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; @@ -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); diff --git a/appexemplo_v2.0/api/api_controllers/Natureza_juridicaAPI.class.php b/appexemplo_v2.0/api/api_controllers/Natureza_juridicaAPI.class.php index 0fc8d4e0..f331ba1d 100644 --- a/appexemplo_v2.0/api/api_controllers/Natureza_juridicaAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/Natureza_juridicaAPI.class.php @@ -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; @@ -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; @@ -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); diff --git a/appexemplo_v2.0/api/api_controllers/PedidoAPI.class.php b/appexemplo_v2.0/api/api_controllers/PedidoAPI.class.php index 8131ec8a..dd941e2b 100644 --- a/appexemplo_v2.0/api/api_controllers/PedidoAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/PedidoAPI.class.php @@ -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; @@ -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; @@ -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); diff --git a/appexemplo_v2.0/api/api_controllers/Pedido_itemAPI.class.php b/appexemplo_v2.0/api/api_controllers/Pedido_itemAPI.class.php index 9d635db9..fc8ada49 100644 --- a/appexemplo_v2.0/api/api_controllers/Pedido_itemAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/Pedido_itemAPI.class.php @@ -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; @@ -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; @@ -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); diff --git a/appexemplo_v2.0/api/api_controllers/PessoaAPI.class.php b/appexemplo_v2.0/api/api_controllers/PessoaAPI.class.php index 55a750e6..dad54e62 100644 --- a/appexemplo_v2.0/api/api_controllers/PessoaAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/PessoaAPI.class.php @@ -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:13 */ namespace api_controllers; @@ -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; @@ -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); diff --git a/appexemplo_v2.0/api/api_controllers/Pessoa_fisicaAPI.class.php b/appexemplo_v2.0/api/api_controllers/Pessoa_fisicaAPI.class.php index ba21b29f..60bb4f89 100644 --- a/appexemplo_v2.0/api/api_controllers/Pessoa_fisicaAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/Pessoa_fisicaAPI.class.php @@ -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:13 */ namespace api_controllers; @@ -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; @@ -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); diff --git a/appexemplo_v2.0/api/api_controllers/Pessoa_juridicaAPI.class.php b/appexemplo_v2.0/api/api_controllers/Pessoa_juridicaAPI.class.php index e366cd22..16962977 100644 --- a/appexemplo_v2.0/api/api_controllers/Pessoa_juridicaAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/Pessoa_juridicaAPI.class.php @@ -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:13 */ namespace api_controllers; @@ -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; @@ -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); diff --git a/appexemplo_v2.0/api/api_controllers/ProdutoAPI.class.php b/appexemplo_v2.0/api/api_controllers/ProdutoAPI.class.php index a8376de9..5318b38d 100644 --- a/appexemplo_v2.0/api/api_controllers/ProdutoAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/ProdutoAPI.class.php @@ -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:13 */ namespace api_controllers; @@ -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; @@ -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); diff --git a/appexemplo_v2.0/api/api_controllers/RegiaoAPI.class.php b/appexemplo_v2.0/api/api_controllers/RegiaoAPI.class.php index 7dd23987..f73ff7bf 100644 --- a/appexemplo_v2.0/api/api_controllers/RegiaoAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/RegiaoAPI.class.php @@ -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:13 */ namespace api_controllers; @@ -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; @@ -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); diff --git a/appexemplo_v2.0/api/api_controllers/SelfilhosmenuAPI.class.php b/appexemplo_v2.0/api/api_controllers/SelfilhosmenuAPI.class.php index 8a4367a0..7d280eb8 100644 --- a/appexemplo_v2.0/api/api_controllers/SelfilhosmenuAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/SelfilhosmenuAPI.class.php @@ -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; @@ -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; diff --git a/appexemplo_v2.0/api/api_controllers/SelfilhosmenuqtdAPI.class.php b/appexemplo_v2.0/api/api_controllers/SelfilhosmenuqtdAPI.class.php index 26b590c8..ba937e29 100644 --- a/appexemplo_v2.0/api/api_controllers/SelfilhosmenuqtdAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/SelfilhosmenuqtdAPI.class.php @@ -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; @@ -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; diff --git a/appexemplo_v2.0/api/api_controllers/TGenericAPI.class.php b/appexemplo_v2.0/api/api_controllers/TGenericAPI.class.php index 528642e5..1d61ec8c 100644 --- a/appexemplo_v2.0/api/api_controllers/TGenericAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/TGenericAPI.class.php @@ -9,7 +9,6 @@ class TGenericAPI public function __construct() { } - public static function getBodyJson($msg, Response $response,$status=200) { $status = empty($status)?200:$status; @@ -18,14 +17,15 @@ public static function getBodyJson($msg, Response $response,$status=200) $response->getBody()->write( $msgJson ); return $response->withStatus( $status ); } - - public static function setObjVoInset(Request $request,$vo) + public static function getSelectNumPage($args) + { + $page = \ArrayHelper::get($args,'page'); + return $page; + } + public static function getSelectNumRowsPerPage($args) { - $bodyRequest = json_decode($request->getBody(),true); - if(empty($bodyRequest)){ - $bodyRequest = $request->getParsedBody(); - } - $vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo); - return $vo; + $rowsPerPage = \ArrayHelper::get($args,'rowsPerPage'); + $rowsPerPage = empty($page)?ROWS_PER_PAGE:$rowsPerPage; + return $rowsPerPage; } } \ No newline at end of file diff --git a/appexemplo_v2.0/api/api_controllers/TelefoneAPI.class.php b/appexemplo_v2.0/api/api_controllers/TelefoneAPI.class.php index 13627b9d..4895ca31 100644 --- a/appexemplo_v2.0/api/api_controllers/TelefoneAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/TelefoneAPI.class.php @@ -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:18 + * System appev2 created in: 2022-09-28 00:42:13 */ namespace api_controllers; @@ -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; @@ -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); diff --git a/appexemplo_v2.0/api/api_controllers/TipoAPI.class.php b/appexemplo_v2.0/api/api_controllers/TipoAPI.class.php index d2591197..82d04e23 100644 --- a/appexemplo_v2.0/api/api_controllers/TipoAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/TipoAPI.class.php @@ -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:18 + * System appev2 created in: 2022-09-28 00:42:13 */ namespace api_controllers; @@ -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; @@ -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); diff --git a/appexemplo_v2.0/api/api_controllers/UfAPI.class.php b/appexemplo_v2.0/api/api_controllers/UfAPI.class.php index a83a02c7..70e4b427 100644 --- a/appexemplo_v2.0/api/api_controllers/UfAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/UfAPI.class.php @@ -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:18 + * System appev2 created in: 2022-09-28 00:42:14 */ namespace api_controllers; @@ -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; @@ -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); diff --git a/appexemplo_v2.0/api/api_controllers/Vw_acesso_user_menuAPI.class.php b/appexemplo_v2.0/api/api_controllers/Vw_acesso_user_menuAPI.class.php index 41a43298..ebba2ee7 100644 --- a/appexemplo_v2.0/api/api_controllers/Vw_acesso_user_menuAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/Vw_acesso_user_menuAPI.class.php @@ -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:18 + * System appev2 created in: 2022-09-28 00:42:14 */ namespace api_controllers; @@ -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; diff --git a/appexemplo_v2.0/api/api_controllers/Vw_pessoaAPI.class.php b/appexemplo_v2.0/api/api_controllers/Vw_pessoaAPI.class.php index fcbabe2f..18d0aea4 100644 --- a/appexemplo_v2.0/api/api_controllers/Vw_pessoaAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/Vw_pessoaAPI.class.php @@ -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:18 + * System appev2 created in: 2022-09-28 00:42:14 */ namespace api_controllers; @@ -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; diff --git a/appexemplo_v2.0/api/api_controllers/Vw_pessoa_fisicaAPI.class.php b/appexemplo_v2.0/api/api_controllers/Vw_pessoa_fisicaAPI.class.php index b23ae469..1bace927 100644 --- a/appexemplo_v2.0/api/api_controllers/Vw_pessoa_fisicaAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/Vw_pessoa_fisicaAPI.class.php @@ -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:18 + * System appev2 created in: 2022-09-28 00:42:14 */ namespace api_controllers; @@ -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; diff --git a/appexemplo_v2.0/api/api_controllers/Vw_pessoa_marca_produtoAPI.class.php b/appexemplo_v2.0/api/api_controllers/Vw_pessoa_marca_produtoAPI.class.php index c5783317..23ae2741 100644 --- a/appexemplo_v2.0/api/api_controllers/Vw_pessoa_marca_produtoAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/Vw_pessoa_marca_produtoAPI.class.php @@ -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:18 + * System appev2 created in: 2022-09-28 00:42:15 */ namespace api_controllers; @@ -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; diff --git a/appexemplo_v2.0/api/api_controllers/Vw_regiao_municipioAPI.class.php b/appexemplo_v2.0/api/api_controllers/Vw_regiao_municipioAPI.class.php index 3b20d8f5..7a7d1345 100644 --- a/appexemplo_v2.0/api/api_controllers/Vw_regiao_municipioAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/Vw_regiao_municipioAPI.class.php @@ -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:18 + * System appev2 created in: 2022-09-28 00:42:15 */ namespace api_controllers; @@ -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; diff --git a/appexemplo_v2.0/controllers/Acesso_menu.class.php b/appexemplo_v2.0/controllers/Acesso_menu.class.php index ba12a183..68cbf64f 100644 --- a/appexemplo_v2.0/controllers/Acesso_menu.class.php +++ b/appexemplo_v2.0/controllers/Acesso_menu.class.php @@ -4,10 +4,10 @@ * Download SysGen: https://github.com/bjverde/sysgen * Download Formdin Framework: https://github.com/bjverde/formDin * - * SysGen Version: 1.9.0-alpha - * FormDin Version: 4.7.5 + * SysGen Version: 1.12.0 + * FormDin Version: 4.19.0 * - * System appev2 created in: 2019-09-10 09:04:46 + * System appev2 created in: 2022-09-28 00:42:11 */ class Acesso_menu { @@ -38,7 +38,7 @@ public function selectMenuByLogin( $login ) { $result = $this->dao->selectMenuByLogin( $login ); return $result; - } + } //-------------------------------------------------------------------------------- public function selectCount( $where=null ) { @@ -58,10 +58,20 @@ public function selectAll( $orderBy=null, $where=null ) return $result; } //-------------------------------------------------------------------------------- + private function validatePkNotExist( $id ) + { + $where=array('IDMENU'=>$id); + $qtd = $this->selectCount($where); + if( empty($qtd) ){ + throw new DomainException(Message::GENERIC_ID_NOT_EXIST); + } + } + //-------------------------------------------------------------------------------- public function save( Acesso_menuVO $objVo ) { $result = null; if( $objVo->getIdmenu() ) { + $this->validatePkNotExist( $objVo->getIdmenu() ); $result = $this->dao->update( $objVo ); } else { $result = $this->dao->insert( $objVo ); @@ -71,6 +81,7 @@ public function save( Acesso_menuVO $objVo ) //-------------------------------------------------------------------------------- public function delete( $id ) { + $this->validatePkNotExist( $id ); $result = $this->dao->delete( $id ); return $result; } diff --git a/appexemplo_v2.0/controllers/Acesso_perfil.class.php b/appexemplo_v2.0/controllers/Acesso_perfil.class.php index 4c33ff6a..81ad9e56 100644 --- a/appexemplo_v2.0/controllers/Acesso_perfil.class.php +++ b/appexemplo_v2.0/controllers/Acesso_perfil.class.php @@ -4,10 +4,10 @@ * Download SysGen: https://github.com/bjverde/sysgen * Download Formdin Framework: https://github.com/bjverde/formDin * - * SysGen Version: 1.9.0-alpha - * FormDin Version: 4.7.5 + * SysGen Version: 1.12.0 + * FormDin Version: 4.19.0 * - * System appev2 created in: 2019-09-10 09:04:46 + * System appev2 created in: 2022-09-28 00:42:11 */ class Acesso_perfil { @@ -65,11 +65,21 @@ public function validar( Acesso_perfilVO $objVo ) $this->validarNomePerfilJaExiste($objVo); } //-------------------------------------------------------------------------------- + private function validatePkNotExist( $id ) + { + $where=array('IDPERFIL'=>$id); + $qtd = $this->selectCount($where); + if( empty($qtd) ){ + throw new DomainException(Message::GENERIC_ID_NOT_EXIST); + } + } + //-------------------------------------------------------------------------------- public function save( Acesso_perfilVO $objVo ) { $result = null; $this->validar($objVo); if( $objVo->getIdperfil() ) { + $this->validatePkNotExist( $objVo->getIdperfil() ); $result = $this->dao->update( $objVo ); } else { $result = $this->dao->insert( $objVo ); @@ -77,17 +87,9 @@ public function save( Acesso_perfilVO $objVo ) return $result; } //-------------------------------------------------------------------------------- - public function validarIdNaoExiste( $id ) - { - $where=array('IDPERFIL'=>$id); - $qtd = $this->selectCount($where); - if($qtd >= 1){ - throw new DomainException('Registro não existe'); - } - } public function delete( $id ) { - $this->validarIdNaoExiste( $id ); + $this->validatePkNotExist( $id ); $result = $this->dao->delete( $id ); return $result; } diff --git a/appexemplo_v2.0/controllers/Acesso_perfil_menu.class.php b/appexemplo_v2.0/controllers/Acesso_perfil_menu.class.php index a5693fce..2a59246a 100644 --- a/appexemplo_v2.0/controllers/Acesso_perfil_menu.class.php +++ b/appexemplo_v2.0/controllers/Acesso_perfil_menu.class.php @@ -4,10 +4,10 @@ * Download SysGen: https://github.com/bjverde/sysgen * Download Formdin Framework: https://github.com/bjverde/formDin * - * SysGen Version: 1.9.0-alpha - * FormDin Version: 4.7.5 + * SysGen Version: 1.12.0 + * FormDin Version: 4.19.0 * - * System appev2 created in: 2019-09-10 09:04:46 + * System appev2 created in: 2022-09-28 00:42:12 */ class Acesso_perfil_menu { @@ -52,10 +52,20 @@ public function selectAll( $orderBy=null, $where=null ) return $result; } //-------------------------------------------------------------------------------- + private function validatePkNotExist( $id ) + { + $where=array('IDPERFILMENU'=>$id); + $qtd = $this->selectCount($where); + if( empty($qtd) ){ + throw new DomainException(Message::GENERIC_ID_NOT_EXIST); + } + } + //-------------------------------------------------------------------------------- public function save( Acesso_perfil_menuVO $objVo ) { $result = null; if( $objVo->getIdperfilmenu() ) { + $this->validatePkNotExist( $objVo->getIdperfilmenu() ); $result = $this->dao->update( $objVo ); } else { $result = $this->dao->insert( $objVo ); @@ -65,6 +75,7 @@ public function save( Acesso_perfil_menuVO $objVo ) //-------------------------------------------------------------------------------- public function delete( $id ) { + $this->validatePkNotExist( $id ); $result = $this->dao->delete( $id ); return $result; } diff --git a/appexemplo_v2.0/controllers/Acesso_perfil_user.class.php b/appexemplo_v2.0/controllers/Acesso_perfil_user.class.php index 740dfbf3..553473f8 100644 --- a/appexemplo_v2.0/controllers/Acesso_perfil_user.class.php +++ b/appexemplo_v2.0/controllers/Acesso_perfil_user.class.php @@ -4,10 +4,10 @@ * Download SysGen: https://github.com/bjverde/sysgen * Download Formdin Framework: https://github.com/bjverde/formDin * - * SysGen Version: 1.9.0-alpha - * FormDin Version: 4.7.5 + * SysGen Version: 1.12.0 + * FormDin Version: 4.19.0 * - * System appev2 created in: 2019-09-10 09:04:46 + * System appev2 created in: 2022-09-28 00:42:12 */ class Acesso_perfil_user { @@ -39,7 +39,7 @@ public function selectByIdUser( $idUser ) $where = array ('IDUSER'=>$idUser); $result = $this->dao->selectAll( null, $where ); return $result; - } + } //-------------------------------------------------------------------------------- public function selectCount( $where=null ) { @@ -59,11 +59,21 @@ public function selectAll( $orderBy=null, $where=null ) return $result; } //-------------------------------------------------------------------------------- + private function validatePkNotExist( $id ) + { + $where=array('IDPERFILUSER'=>$id); + $qtd = $this->selectCount($where); + if( empty($qtd) ){ + throw new DomainException(Message::GENERIC_ID_NOT_EXIST); + } + } + //-------------------------------------------------------------------------------- public function save( Acesso_perfil_userVO $objVo ) { $result = null; $objVo->setSit_ativo('S'); if( $objVo->getIdperfiluser() ) { + $this->validatePkNotExist( $objVo->getIdperfiluser() ); $result = $this->dao->update( $objVo ); } else { $result = $this->dao->insert( $objVo ); @@ -73,6 +83,7 @@ public function save( Acesso_perfil_userVO $objVo ) //-------------------------------------------------------------------------------- public function delete( $id ) { + $this->validatePkNotExist( $id ); $result = $this->dao->delete( $id ); return $result; } @@ -81,7 +92,7 @@ public function deleteByIdUser( $id ) { $result = $this->dao->deleteByIdUser( $id ); return $result; - } + } //-------------------------------------------------------------------------------- public function getVoById( $id ) {