From 131407b85602839b9aafab4fc78f8069796f4150 Mon Sep 17 00:00:00 2001 From: Bjverde Date: Tue, 27 Sep 2022 16:06:58 -0300 Subject: [PATCH] :hammer: APP #270 update api controller --- .../SelfilhosmenuqtdAPI.class.php | 52 ++++++--- .../api/api_controllers/TelefoneAPI.class.php | 110 ++++++++++++------ .../api/api_controllers/TipoAPI.class.php | 110 ++++++++++++------ .../api/api_controllers/UfAPI.class.php | 110 ++++++++++++------ .../Vw_acesso_user_menuAPI.class.php | 52 ++++++--- .../api_controllers/Vw_pessoaAPI.class.php | 52 ++++++--- .../Vw_pessoa_fisicaAPI.class.php | 52 ++++++--- .../Vw_pessoa_marca_produtoAPI.class.php | 52 ++++++--- .../Vw_regiao_municipioAPI.class.php | 52 ++++++--- 9 files changed, 426 insertions(+), 216 deletions(-) diff --git a/appexemplo_v2.0/api/api_controllers/SelfilhosmenuqtdAPI.class.php b/appexemplo_v2.0/api/api_controllers/SelfilhosmenuqtdAPI.class.php index ea85c65f..26b590c8 100644 --- a/appexemplo_v2.0/api/api_controllers/SelfilhosmenuqtdAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/SelfilhosmenuqtdAPI.class.php @@ -7,7 +7,7 @@ * SysGen Version: 1.11.0 * FormDin Version: 4.19.0 * - * System appev2 created in: 2022-07-30 16:51:53 + * System appev2 created in: 2022-09-27 15:40:16 */ namespace api_controllers; @@ -25,15 +25,28 @@ public function __construct() //-------------------------------------------------------------------------------- public static function selectAll(Request $request, Response $response, array $args) { - $controller = new \Selfilhosmenuqtd(); - $result = $controller->selectAll(); - $result = \ArrayHelper::convertArrayFormDin2Pdo($result); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $param = $request->getQueryParams(); + $page = TGenericAPI::getSelectNumPage($param); + $rowsPerPage = TGenericAPI::getSelectNumRowsPerPage($param); + $orderBy = null; + $where = array(); + $controller = new \Selfilhosmenuqtd(); + //$result = $controller->selectAll(); + $qtd_total = $controller->selectCount( $where ); + $result = $controller->selectAllPagination( $orderBy, $where, $page, $rowsPerPage); + $result = \ArrayHelper::convertArrayFormDin2Pdo($result); + $msg = array( 'qtd_total'=> $qtd_total + , 'qtd_result'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } //-------------------------------------------------------------------------------- @@ -49,12 +62,17 @@ private static function selectByIdInside(array $args) //-------------------------------------------------------------------------------- public static function selectById(Request $request, Response $response, array $args) { - $result = self::selectByIdInside($args); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $result = self::selectByIdInside($args); + $msg = array( 'qtd'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } } \ 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 c89741d2..13627b9d 100644 --- a/appexemplo_v2.0/api/api_controllers/TelefoneAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/TelefoneAPI.class.php @@ -7,7 +7,7 @@ * SysGen Version: 1.11.0 * FormDin Version: 4.19.0 * - * System appev2 created in: 2022-07-30 16:51:56 + * System appev2 created in: 2022-09-27 15:40:18 */ namespace api_controllers; @@ -25,15 +25,28 @@ public function __construct() //-------------------------------------------------------------------------------- public static function selectAll(Request $request, Response $response, array $args) { - $controller = new \Telefone(); - $result = $controller->selectAll(); - $result = \ArrayHelper::convertArrayFormDin2Pdo($result); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $param = $request->getQueryParams(); + $page = TGenericAPI::getSelectNumPage($param); + $rowsPerPage = TGenericAPI::getSelectNumRowsPerPage($param); + $orderBy = null; + $where = array(); + $controller = new \Telefone(); + //$result = $controller->selectAll(); + $qtd_total = $controller->selectCount( $where ); + $result = $controller->selectAllPagination( $orderBy, $where, $page, $rowsPerPage); + $result = \ArrayHelper::convertArrayFormDin2Pdo($result); + $msg = array( 'qtd_total'=> $qtd_total + , 'qtd_result'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } //-------------------------------------------------------------------------------- @@ -49,45 +62,66 @@ private static function selectByIdInside(array $args) //-------------------------------------------------------------------------------- public static function selectById(Request $request, Response $response, array $args) { - $result = self::selectByIdInside($args); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $result = self::selectByIdInside($args); + $msg = array( 'qtd'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } //-------------------------------------------------------------------------------- public static function save(Request $request, Response $response, array $args) { - $vo = new \TelefoneVO; - $msg = \Message::GENERIC_INSERT; - if($request->isPut()){ - $msg = \Message::GENERIC_UPDATE; - $result = self::selectByIdInside($args); - $bodyRequest = $result[0]; + try{ + $vo = new \TelefoneVO; + $msg = \Message::GENERIC_INSERT; + if($request->getMethod() == 'PUT'){ + $msg = \Message::GENERIC_UPDATE; + $result = self::selectByIdInside($args); + $bodyRequest = $result[0]; + $vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo); + } + $bodyRequest = json_decode($request->getBody(),true); + if( empty($bodyRequest) ){ + $bodyRequest = $request->getParsedBody(); + } $vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo); - } - $bodyRequest = json_decode($request->getBody(),true); - $vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo); - - $controller = new \Telefone; - $controller->save($vo); + $controller = new \Telefone; + $controller->save($vo); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } //-------------------------------------------------------------------------------- public static function delete(Request $request, Response $response, array $args) { - $id = $args['id']; - $controller = new \Telefone; - $msg = $controller->delete($id); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $id = $args['id']; + $controller = new \Telefone; + $msg = $controller->delete($id); + if($msg==true){ + $msg = \Message::GENERIC_DELETE; + $msg = $msg.' id='.$id; + } + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } } \ No newline at end of file diff --git a/appexemplo_v2.0/api/api_controllers/TipoAPI.class.php b/appexemplo_v2.0/api/api_controllers/TipoAPI.class.php index 508e2a8a..d2591197 100644 --- a/appexemplo_v2.0/api/api_controllers/TipoAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/TipoAPI.class.php @@ -7,7 +7,7 @@ * SysGen Version: 1.11.0 * FormDin Version: 4.19.0 * - * System appev2 created in: 2022-07-30 16:51:56 + * System appev2 created in: 2022-09-27 15:40:18 */ namespace api_controllers; @@ -25,15 +25,28 @@ public function __construct() //-------------------------------------------------------------------------------- public static function selectAll(Request $request, Response $response, array $args) { - $controller = new \Tipo(); - $result = $controller->selectAll(); - $result = \ArrayHelper::convertArrayFormDin2Pdo($result); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $param = $request->getQueryParams(); + $page = TGenericAPI::getSelectNumPage($param); + $rowsPerPage = TGenericAPI::getSelectNumRowsPerPage($param); + $orderBy = null; + $where = array(); + $controller = new \Tipo(); + //$result = $controller->selectAll(); + $qtd_total = $controller->selectCount( $where ); + $result = $controller->selectAllPagination( $orderBy, $where, $page, $rowsPerPage); + $result = \ArrayHelper::convertArrayFormDin2Pdo($result); + $msg = array( 'qtd_total'=> $qtd_total + , 'qtd_result'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } //-------------------------------------------------------------------------------- @@ -49,45 +62,66 @@ private static function selectByIdInside(array $args) //-------------------------------------------------------------------------------- public static function selectById(Request $request, Response $response, array $args) { - $result = self::selectByIdInside($args); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $result = self::selectByIdInside($args); + $msg = array( 'qtd'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } //-------------------------------------------------------------------------------- public static function save(Request $request, Response $response, array $args) { - $vo = new \TipoVO; - $msg = \Message::GENERIC_INSERT; - if($request->isPut()){ - $msg = \Message::GENERIC_UPDATE; - $result = self::selectByIdInside($args); - $bodyRequest = $result[0]; + try{ + $vo = new \TipoVO; + $msg = \Message::GENERIC_INSERT; + if($request->getMethod() == 'PUT'){ + $msg = \Message::GENERIC_UPDATE; + $result = self::selectByIdInside($args); + $bodyRequest = $result[0]; + $vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo); + } + $bodyRequest = json_decode($request->getBody(),true); + if( empty($bodyRequest) ){ + $bodyRequest = $request->getParsedBody(); + } $vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo); - } - $bodyRequest = json_decode($request->getBody(),true); - $vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo); - - $controller = new \Tipo; - $controller->save($vo); + $controller = new \Tipo; + $controller->save($vo); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } //-------------------------------------------------------------------------------- public static function delete(Request $request, Response $response, array $args) { - $id = $args['id']; - $controller = new \Tipo; - $msg = $controller->delete($id); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $id = $args['id']; + $controller = new \Tipo; + $msg = $controller->delete($id); + if($msg==true){ + $msg = \Message::GENERIC_DELETE; + $msg = $msg.' id='.$id; + } + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } } \ No newline at end of file diff --git a/appexemplo_v2.0/api/api_controllers/UfAPI.class.php b/appexemplo_v2.0/api/api_controllers/UfAPI.class.php index 916b2028..a83a02c7 100644 --- a/appexemplo_v2.0/api/api_controllers/UfAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/UfAPI.class.php @@ -7,7 +7,7 @@ * SysGen Version: 1.11.0 * FormDin Version: 4.19.0 * - * System appev2 created in: 2022-07-30 16:51:57 + * System appev2 created in: 2022-09-27 15:40:18 */ namespace api_controllers; @@ -25,15 +25,28 @@ public function __construct() //-------------------------------------------------------------------------------- public static function selectAll(Request $request, Response $response, array $args) { - $controller = new \Uf(); - $result = $controller->selectAll(); - $result = \ArrayHelper::convertArrayFormDin2Pdo($result); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $param = $request->getQueryParams(); + $page = TGenericAPI::getSelectNumPage($param); + $rowsPerPage = TGenericAPI::getSelectNumRowsPerPage($param); + $orderBy = null; + $where = array(); + $controller = new \Uf(); + //$result = $controller->selectAll(); + $qtd_total = $controller->selectCount( $where ); + $result = $controller->selectAllPagination( $orderBy, $where, $page, $rowsPerPage); + $result = \ArrayHelper::convertArrayFormDin2Pdo($result); + $msg = array( 'qtd_total'=> $qtd_total + , 'qtd_result'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } //-------------------------------------------------------------------------------- @@ -49,45 +62,66 @@ private static function selectByIdInside(array $args) //-------------------------------------------------------------------------------- public static function selectById(Request $request, Response $response, array $args) { - $result = self::selectByIdInside($args); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $result = self::selectByIdInside($args); + $msg = array( 'qtd'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } //-------------------------------------------------------------------------------- public static function save(Request $request, Response $response, array $args) { - $vo = new \UfVO; - $msg = \Message::GENERIC_INSERT; - if($request->isPut()){ - $msg = \Message::GENERIC_UPDATE; - $result = self::selectByIdInside($args); - $bodyRequest = $result[0]; + try{ + $vo = new \UfVO; + $msg = \Message::GENERIC_INSERT; + if($request->getMethod() == 'PUT'){ + $msg = \Message::GENERIC_UPDATE; + $result = self::selectByIdInside($args); + $bodyRequest = $result[0]; + $vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo); + } + $bodyRequest = json_decode($request->getBody(),true); + if( empty($bodyRequest) ){ + $bodyRequest = $request->getParsedBody(); + } $vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo); - } - $bodyRequest = json_decode($request->getBody(),true); - $vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo); - - $controller = new \Uf; - $controller->save($vo); + $controller = new \Uf; + $controller->save($vo); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } //-------------------------------------------------------------------------------- public static function delete(Request $request, Response $response, array $args) { - $id = $args['id']; - $controller = new \Uf; - $msg = $controller->delete($id); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $id = $args['id']; + $controller = new \Uf; + $msg = $controller->delete($id); + if($msg==true){ + $msg = \Message::GENERIC_DELETE; + $msg = $msg.' id='.$id; + } + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } } \ No newline at end of file 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 c0eb209d..41a43298 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 @@ -7,7 +7,7 @@ * SysGen Version: 1.11.0 * FormDin Version: 4.19.0 * - * System appev2 created in: 2022-07-30 16:51:57 + * System appev2 created in: 2022-09-27 15:40:18 */ namespace api_controllers; @@ -25,15 +25,28 @@ public function __construct() //-------------------------------------------------------------------------------- public static function selectAll(Request $request, Response $response, array $args) { - $controller = new \Vw_acesso_user_menu(); - $result = $controller->selectAll(); - $result = \ArrayHelper::convertArrayFormDin2Pdo($result); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $param = $request->getQueryParams(); + $page = TGenericAPI::getSelectNumPage($param); + $rowsPerPage = TGenericAPI::getSelectNumRowsPerPage($param); + $orderBy = null; + $where = array(); + $controller = new \Vw_acesso_user_menu(); + //$result = $controller->selectAll(); + $qtd_total = $controller->selectCount( $where ); + $result = $controller->selectAllPagination( $orderBy, $where, $page, $rowsPerPage); + $result = \ArrayHelper::convertArrayFormDin2Pdo($result); + $msg = array( 'qtd_total'=> $qtd_total + , 'qtd_result'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } //-------------------------------------------------------------------------------- @@ -49,12 +62,17 @@ private static function selectByIdInside(array $args) //-------------------------------------------------------------------------------- public static function selectById(Request $request, Response $response, array $args) { - $result = self::selectByIdInside($args); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $result = self::selectByIdInside($args); + $msg = array( 'qtd'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } } \ No newline at end of file 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 36980840..fcbabe2f 100644 --- a/appexemplo_v2.0/api/api_controllers/Vw_pessoaAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/Vw_pessoaAPI.class.php @@ -7,7 +7,7 @@ * SysGen Version: 1.11.0 * FormDin Version: 4.19.0 * - * System appev2 created in: 2022-07-30 16:51:57 + * System appev2 created in: 2022-09-27 15:40:18 */ namespace api_controllers; @@ -25,15 +25,28 @@ public function __construct() //-------------------------------------------------------------------------------- public static function selectAll(Request $request, Response $response, array $args) { - $controller = new \Vw_pessoa(); - $result = $controller->selectAll(); - $result = \ArrayHelper::convertArrayFormDin2Pdo($result); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $param = $request->getQueryParams(); + $page = TGenericAPI::getSelectNumPage($param); + $rowsPerPage = TGenericAPI::getSelectNumRowsPerPage($param); + $orderBy = null; + $where = array(); + $controller = new \Vw_pessoa(); + //$result = $controller->selectAll(); + $qtd_total = $controller->selectCount( $where ); + $result = $controller->selectAllPagination( $orderBy, $where, $page, $rowsPerPage); + $result = \ArrayHelper::convertArrayFormDin2Pdo($result); + $msg = array( 'qtd_total'=> $qtd_total + , 'qtd_result'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } //-------------------------------------------------------------------------------- @@ -49,12 +62,17 @@ private static function selectByIdInside(array $args) //-------------------------------------------------------------------------------- public static function selectById(Request $request, Response $response, array $args) { - $result = self::selectByIdInside($args); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $result = self::selectByIdInside($args); + $msg = array( 'qtd'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } } \ No newline at end of file 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 b38563f9..b23ae469 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 @@ -7,7 +7,7 @@ * SysGen Version: 1.11.0 * FormDin Version: 4.19.0 * - * System xx created in: 2022-07-30 16:51:57 + * System appev2 created in: 2022-09-27 15:40:18 */ namespace api_controllers; @@ -25,15 +25,28 @@ public function __construct() //-------------------------------------------------------------------------------- public static function selectAll(Request $request, Response $response, array $args) { - $controller = new \Vw_pessoa_fisica(); - $result = $controller->selectAll(); - $result = \ArrayHelper::convertArrayFormDin2Pdo($result); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $param = $request->getQueryParams(); + $page = TGenericAPI::getSelectNumPage($param); + $rowsPerPage = TGenericAPI::getSelectNumRowsPerPage($param); + $orderBy = null; + $where = array(); + $controller = new \Vw_pessoa_fisica(); + //$result = $controller->selectAll(); + $qtd_total = $controller->selectCount( $where ); + $result = $controller->selectAllPagination( $orderBy, $where, $page, $rowsPerPage); + $result = \ArrayHelper::convertArrayFormDin2Pdo($result); + $msg = array( 'qtd_total'=> $qtd_total + , 'qtd_result'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } //-------------------------------------------------------------------------------- @@ -49,12 +62,17 @@ private static function selectByIdInside(array $args) //-------------------------------------------------------------------------------- public static function selectById(Request $request, Response $response, array $args) { - $result = self::selectByIdInside($args); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $result = self::selectByIdInside($args); + $msg = array( 'qtd'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } } \ No newline at end of file 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 228ae0db..c5783317 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 @@ -7,7 +7,7 @@ * SysGen Version: 1.11.0 * FormDin Version: 4.19.0 * - * System appev2 created in: 2022-07-30 16:51:57 + * System appev2 created in: 2022-09-27 15:40:18 */ namespace api_controllers; @@ -25,15 +25,28 @@ public function __construct() //-------------------------------------------------------------------------------- public static function selectAll(Request $request, Response $response, array $args) { - $controller = new \Vw_pessoa_marca_produto(); - $result = $controller->selectAll(); - $result = \ArrayHelper::convertArrayFormDin2Pdo($result); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $param = $request->getQueryParams(); + $page = TGenericAPI::getSelectNumPage($param); + $rowsPerPage = TGenericAPI::getSelectNumRowsPerPage($param); + $orderBy = null; + $where = array(); + $controller = new \Vw_pessoa_marca_produto(); + //$result = $controller->selectAll(); + $qtd_total = $controller->selectCount( $where ); + $result = $controller->selectAllPagination( $orderBy, $where, $page, $rowsPerPage); + $result = \ArrayHelper::convertArrayFormDin2Pdo($result); + $msg = array( 'qtd_total'=> $qtd_total + , 'qtd_result'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } //-------------------------------------------------------------------------------- @@ -49,12 +62,17 @@ private static function selectByIdInside(array $args) //-------------------------------------------------------------------------------- public static function selectById(Request $request, Response $response, array $args) { - $result = self::selectByIdInside($args); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $result = self::selectByIdInside($args); + $msg = array( 'qtd'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } } \ No newline at end of file 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 dfc364e4..3b20d8f5 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 @@ -7,7 +7,7 @@ * SysGen Version: 1.11.0 * FormDin Version: 4.19.0 * - * System xx created in: 2022-07-30 16:51:57 + * System appev2 created in: 2022-09-27 15:40:18 */ namespace api_controllers; @@ -25,15 +25,28 @@ public function __construct() //-------------------------------------------------------------------------------- public static function selectAll(Request $request, Response $response, array $args) { - $controller = new \Vw_regiao_municipio(); - $result = $controller->selectAll(); - $result = \ArrayHelper::convertArrayFormDin2Pdo($result); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $param = $request->getQueryParams(); + $page = TGenericAPI::getSelectNumPage($param); + $rowsPerPage = TGenericAPI::getSelectNumRowsPerPage($param); + $orderBy = null; + $where = array(); + $controller = new \Vw_regiao_municipio(); + //$result = $controller->selectAll(); + $qtd_total = $controller->selectCount( $where ); + $result = $controller->selectAllPagination( $orderBy, $where, $page, $rowsPerPage); + $result = \ArrayHelper::convertArrayFormDin2Pdo($result); + $msg = array( 'qtd_total'=> $qtd_total + , 'qtd_result'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } //-------------------------------------------------------------------------------- @@ -49,12 +62,17 @@ private static function selectByIdInside(array $args) //-------------------------------------------------------------------------------- public static function selectById(Request $request, Response $response, array $args) { - $result = self::selectByIdInside($args); - $msg = array( 'qtd'=> \CountHelper::count($result) - , 'result'=>$result - ); - - $response = TGenericAPI::getBodyJson($msg,$response); - return $response; + try{ + $result = self::selectByIdInside($args); + $msg = array( 'qtd'=> \CountHelper::count($result) + , 'result'=>$result + ); + $response = TGenericAPI::getBodyJson($msg,$response,200); + return $response; + } catch ( \Exception $e) { + $msg = $e->getMessage(); + $response = TGenericAPI::getBodyJson($msg,$response,500); + return $response; + } } } \ No newline at end of file