Skip to content

Commit

Permalink
🔨 #118 alterando delete
Browse files Browse the repository at this point in the history
  • Loading branch information
bjverde committed Sep 27, 2022
1 parent faf5a76 commit eb06bce
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions controllers/CreateApiControllesFiles.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ public function addConstruct()
$this->addLine(ESP.'}');
}
//--------------------------------------------------------------------------------------
public function addBodyJsonResponse()
public function addBodyJsonResponse($qtdEspacos,$status)
{
$this->addBlankLine();
$this->addLine(ESP.ESP.'$response = TGenericAPI::getBodyJson($msg,$response);');
$this->addLine(ESP.ESP.'return $response;');
$this->addLine($qtdEspacos.'$response = TGenericAPI::getBodyJson($msg,$response,'.$status.');');
$this->addLine($qtdEspacos.'return $response;');
}
//--------------------------------------------------------------------------------------
public function addSelectAll()
Expand Down Expand Up @@ -180,10 +180,19 @@ public function addDelete()
$this->addLine();
$this->addLine(ESP.'public static function delete(Request $request, Response $response, array $args)');
$this->addLine(ESP.'{');
$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->addBodyJsonResponse();
$this->addLine(ESP.ESP.'try{');
$this->addLine(ESP.ESP.ESP.'$id = $args[\'id\'];');
$this->addLine(ESP.ESP.ESP.'$controller = new \\'.ucfirst( $this->getTableName() ).';');
$this->addLine(ESP.ESP.ESP.'$msg = $controller->delete($id);');
$this->addLine(ESP.ESP.ESP.'if($msg==true){');
$this->addLine(ESP.ESP.ESP.ESP.'$msg = \Message::GENERIC_DELETE;');
$this->addLine(ESP.ESP.ESP.ESP.'$msg = $msg.\' id=\'.$id;');
$this->addLine(ESP.ESP.ESP.'}');
$this->addBodyJsonResponse(ESP.ESP.ESP,200);
$this->addLine(ESP.ESP.'} catch ( \Exception $e) {');
$this->addLine(ESP.ESP.ESP.'$msg = $e->getMessage();');
$this->addBodyJsonResponse(ESP.ESP.ESP,500);
$this->addLine(ESP.ESP.'}');
$this->addLine(ESP.'}');
}
//--------------------------------------------------------------------------------------
Expand Down

0 comments on commit eb06bce

Please sign in to comment.