Skip to content

Commit

Permalink
📝 APP #220 melhorando API
Browse files Browse the repository at this point in the history
  • Loading branch information
bjverde committed Mar 22, 2020
1 parent 034d602 commit 900c7e5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
23 changes: 19 additions & 4 deletions appexemplo_v3.0/controllers/Regiao.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,17 @@ public function selectCount( $where=null )
//--------------------------------------------------------------------------------
public function selectAllPagination( $orderBy=null, $where=null, $page=null, $rowsPerPage= null)
{
$result = $this->dao->selectAllPagination( $orderBy, $where, $page, $rowsPerPage );
$headers = [
'Accept' => 'application/json'
];
$response = $this->client->request('GET', 'regiao/', [
'headers' => $headers
]);
if($response->getStatusCode()==200){
$result = $response->getBody();
}else{
$result = 'erro';
}
return $result;
}
//--------------------------------------------------------------------------------
Expand All @@ -62,13 +72,18 @@ public function save( RegiaoVO $objVo )
$objJson = FormDinHelper::convertVo2Json($objVo);
$result = null;
$response = null;
$headers = [
'Accept' => 'application/json'
];
if( $objVo->getCod_regiao() ) {
$response = $this->client->request('PUT', 'regiao/'.$objVo->getCod_regiao(), [
'json' => $objJson
'headers' => $headers
,'json' => $objJson
]);
} else {
$response = $this->client->request('POST', 'regiao', [
'json' => $objJson
$response = $this->client->request('POST', 'regiao/', [
'headers' => $headers
,'json' => $objJson
]);
}
if($response->getStatusCode()==200){
Expand Down
1 change: 1 addition & 0 deletions appexemplo_v3.0/modulos/regiao.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ function getWhereGridParameters(&$frm)
$controller = new Regiao();
$page = PostHelper::get('page');
$dados = $controller->selectAllPagination( $primaryKey, $whereGrid, $page, $maxRows);
var_dump($dados);
$realTotalRowsSqlPaginator = $controller->selectCount( $whereGrid );
$mixUpdateFields = $primaryKey.'|'.$primaryKey
.',NOM_REGIAO|NOM_REGIAO'
Expand Down

0 comments on commit 900c7e5

Please sign in to comment.