From f8436a09771c9d73df6089add7a219c810be1bca Mon Sep 17 00:00:00 2001 From: Bjverde Date: Sat, 30 Jul 2022 14:10:49 -0300 Subject: [PATCH] :hammer: #270 alterando chamadas --- .../api_controllers/Meta_tipoAPI.class.php | 21 ++++++++----------- .../SelfilhosmenuAPI.class.php | 4 ++-- appexemplo_v2.0/api/routes2.php | 14 +++++++++++++ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/appexemplo_v2.0/api/api_controllers/Meta_tipoAPI.class.php b/appexemplo_v2.0/api/api_controllers/Meta_tipoAPI.class.php index d102ec24..95ea80a6 100644 --- a/appexemplo_v2.0/api/api_controllers/Meta_tipoAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/Meta_tipoAPI.class.php @@ -31,9 +31,8 @@ public static function selectAll(Request $request, Response $response, array $ar $msg = array( 'qtd'=> \CountHelper::count($result) , 'result'=>$result ); - $msgJson = json_encode($msg); - $response->getBody()->write( $msgJson ); - return $response->withHeader('Content-Type', 'application/json'); + $response = TGenericAPI::getBodyJson($msg,$response); + return $response; } //-------------------------------------------------------------------------------- @@ -53,9 +52,8 @@ public static function selectById(Request $request, Response $response, array $a $msg = array( 'qtd'=> \CountHelper::count($result) , 'result'=>$result ); - $msgJson = json_encode($msg); - $response->getBody()->write( $msgJson ); - return $response->withHeader('Content-Type', 'application/json'); + $response = TGenericAPI::getBodyJson($msg,$response); + return $response; } //-------------------------------------------------------------------------------- @@ -75,9 +73,8 @@ public static function save(Request $request, Response $response, array $args) $controller = new \Meta_tipo; $controller->save($vo); - $msgJson = json_encode($msg); - $response->getBody()->write( $msgJson ); - return $response->withHeader('Content-Type', 'application/json'); + $response = TGenericAPI::getBodyJson($msg,$response); + return $response; } //-------------------------------------------------------------------------------- @@ -86,8 +83,8 @@ public static function delete(Request $request, Response $response, array $args) $id = $args['id']; $controller = new \Meta_tipo; $msg = $controller->delete($id); - $msgJson = json_encode($msg); - $response->getBody()->write( $msgJson ); - return $response->withHeader('Content-Type', 'application/json'); + + $response = TGenericAPI::getBodyJson($msg,$response); + return $response; } } \ No newline at end of file diff --git a/appexemplo_v2.0/api/api_controllers/SelfilhosmenuAPI.class.php b/appexemplo_v2.0/api/api_controllers/SelfilhosmenuAPI.class.php index cade7999..b0be211c 100644 --- a/appexemplo_v2.0/api/api_controllers/SelfilhosmenuAPI.class.php +++ b/appexemplo_v2.0/api/api_controllers/SelfilhosmenuAPI.class.php @@ -31,7 +31,7 @@ public static function selectAll(Request $request, Response $response, array $ar $msg = array( 'qtd'=> \CountHelper::count($result) , 'result'=>$result ); - $response = $response->withJson($msg); + $response = TGenericAPI::getBodyJson($msg,$response); return $response; } @@ -52,7 +52,7 @@ public static function selectById(Request $request, Response $response, array $a $msg = array( 'qtd'=> \CountHelper::count($result) , 'result'=>$result ); - $response = $response->withJson($msg); + $response = TGenericAPI::getBodyJson($msg,$response); return $response; } } \ No newline at end of file diff --git a/appexemplo_v2.0/api/routes2.php b/appexemplo_v2.0/api/routes2.php index 520e8ff5..15dc7e8c 100644 --- a/appexemplo_v2.0/api/routes2.php +++ b/appexemplo_v2.0/api/routes2.php @@ -113,6 +113,20 @@ $app->get($urlGrupo.'/{id:[0-9]+}', SelfilhosmenuqtdAPI::class . ':selectById'); }); +//-------------------------------------------------------------------- +// TABLE: acesso_menu +//-------------------------------------------------------------------- +$urlGrupo = $urlChamada.'acesso_menu'; +$app->group($urlGrupo, function(RouteCollectorProxy $group) use ($app,$urlGrupo) { + $app->get($urlGrupo.'', Acesso_menuAPI::class . ':selectAll'); + $app->get($urlGrupo.'/{id:[0-9]+}', Acesso_menuAPI::class . ':selectById'); + + + $app->post($urlGrupo.'', Acesso_menuAPI::class . ':save'); + $app->put($urlGrupo.'/{id:[0-9]+}', Acesso_menuAPI::class . ':save'); + $app->delete($urlGrupo.'/{id:[0-9]+}', Acesso_menuAPI::class . ':delete'); +}); + //-------------------------------------------------------------------- // TABLE: meta_tipo //--------------------------------------------------------------------