From 3349794b0291413c1bf00a3a5ef6e2a039132d3b Mon Sep 17 00:00:00 2001 From: Bjverde Date: Sat, 30 Jul 2022 15:07:20 -0300 Subject: [PATCH] :hammer: #118 alterando a resposta --- .../CreateApiControllesFiles.class.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/controllers/CreateApiControllesFiles.class.php b/controllers/CreateApiControllesFiles.class.php index 29cea60..2053bd6 100644 --- a/controllers/CreateApiControllesFiles.class.php +++ b/controllers/CreateApiControllesFiles.class.php @@ -83,6 +83,13 @@ public function addConstruct() $this->addLine(ESP.'}'); } //-------------------------------------------------------------------------------------- + public function addBodyJsonResponse() + { + $this->addBlankLine(); + $this->addLine(ESP.ESP.'$response = TGenericAPI::getBodyJson($msg,$response);'); + $this->addLine(ESP.ESP.'return $response;'); + } + //-------------------------------------------------------------------------------------- public function addSelectAll() { $this->addBlankLine(); @@ -95,8 +102,7 @@ public function addSelectAll() $this->addLine(ESP.ESP.'$msg = array( \'qtd\'=> \CountHelper::count($result)'); $this->addLine(ESP.ESP.ESP.ESP.ESP.', \'result\'=>$result'); $this->addLine(ESP.ESP.');'); - $this->addLine(ESP.ESP.'$response = $response->withJson($msg);'); - $this->addLine(ESP.ESP.'return $response;'); + $this->addBodyJsonResponse(); $this->addLine(ESP.'}'); } //-------------------------------------------------------------------------------------- @@ -124,8 +130,7 @@ public function addSelectById() $this->addLine(ESP.ESP.'$msg = array( \'qtd\'=> \CountHelper::count($result)'); $this->addLine(ESP.ESP.ESP.ESP.ESP.', \'result\'=>$result'); $this->addLine(ESP.ESP.');'); - $this->addLine(ESP.ESP.'$response = $response->withJson($msg);'); - $this->addLine(ESP.ESP.'return $response;'); + $this->addBodyJsonResponse(); $this->addLine(ESP.'}'); } //-------------------------------------------------------------------------------------- @@ -165,8 +170,7 @@ public function addSave() $this->addLine(ESP.ESP.'$controller = new \\'.ucfirst( $this->getTableName() ).';'); $this->addLine(ESP.ESP.'$controller->save($vo);'); $this->addBlankLine(); - $this->addLine(ESP.ESP.'$response = $response->withJson($msg);'); - $this->addLine(ESP.ESP.'return $response;'); + $this->addBodyJsonResponse(); $this->addLine(ESP.'}'); } //-------------------------------------------------------------------------------------- @@ -179,8 +183,7 @@ public function addDelete() $this->addLine(ESP.ESP.'$id = $args[\'id\'];'); $this->addLine(ESP.ESP.'$controller = new \\'.ucfirst( $this->getTableName() ).';'); $this->addLine(ESP.ESP.'$msg = $controller->delete($id);'); - $this->addLine(ESP.ESP.'$response = $response->withJson($msg);'); - $this->addLine(ESP.ESP.'return $response;'); + $this->addBodyJsonResponse(); $this->addLine(ESP.'}'); } //--------------------------------------------------------------------------------------