Skip to content

Commit

Permalink
🐛 #118 correção quando id não existe no update
Browse files Browse the repository at this point in the history
  • Loading branch information
bjverde committed Sep 27, 2022
1 parent 6708210 commit ebdbc0d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion controllers/CreateApiControllesFiles.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ public function addSave()
$this->addLine(ESP.ESP.ESP.'if($request->getMethod() == \'PUT\'){');
$this->addLine(ESP.ESP.ESP.ESP.'$msg = \Message::GENERIC_UPDATE;');
$this->addLine(ESP.ESP.ESP.ESP.'$result = self::selectByIdInside($args);');
$this->addLine(ESP.ESP.ESP.ESP.'$bodyRequest = $result[0];');
$this->addLine(ESP.ESP.ESP.ESP.'$bodyRequest = \ArrayHelper::get($result,0);');
$this->addLine(ESP.ESP.ESP.ESP.'if( empty($bodyRequest) ){');
$this->addLine(ESP.ESP.ESP.ESP.ESP.'throw new \DomainException(Message::GENERIC_ID_NOT_EXIST);');
$this->addLine(ESP.ESP.ESP.ESP.'}');
$this->addLine(ESP.ESP.ESP.ESP.'$vo = \FormDinHelper::setPropertyVo($bodyRequest,$vo);');
$this->addLine(ESP.ESP.ESP.'}');
$this->addLine(ESP.ESP.ESP.'$bodyRequest = json_decode($request->getBody(),true);');
Expand Down
2 changes: 2 additions & 0 deletions system_skeleton/common/controllers/Message.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ class Message {
const GENERIC_DELETE = 'Registro excluído com sucesso!';
const GENERIC_EXEC = 'Ação executada com sucesso!';

const GENERIC_ID_NOT_EXIST = 'Registro não existe';

const TYPE_NOT_INT = 'Tipo não númerico! ';
}

0 comments on commit ebdbc0d

Please sign in to comment.