diff --git a/controllers/CreateApiControllesFiles.class.php b/controllers/CreateApiControllesFiles.class.php index 2053bd6..a86127a 100644 --- a/controllers/CreateApiControllesFiles.class.php +++ b/controllers/CreateApiControllesFiles.class.php @@ -96,8 +96,14 @@ public function addSelectAll() $this->addLine(); $this->addLine(ESP.'public static function selectAll(Request $request, Response $response, array $args)'); $this->addLine(ESP.'{'); + $this->addLine(ESP.ESP.'$page = TGenericAPI::getSelectNumPage($args);'); + $this->addLine(ESP.ESP.'$rowsPerPage = TGenericAPI::getSelectNumRowsPerPage($args);'); + $this->addLine(ESP.ESP.'$orderBy = null;'); + $this->addLine(ESP.ESP.'$where = array();'); + $this->addLine(); $this->addLine(ESP.ESP.'$controller = new \\'.ucfirst( $this->getTableName() ).'();'); - $this->addLine(ESP.ESP.'$result = $controller->selectAll();'); + $this->addLine(ESP.ESP.'//$result = $controller->selectAll();'); + $this->addLine(ESP.ESP.'$result = $controller->selectAllPagination( $orderBy, $where, $page, $rowsPerPage);'); $this->addLine(ESP.ESP.'$result = \ArrayHelper::convertArrayFormDin2Pdo($result);'); $this->addLine(ESP.ESP.'$msg = array( \'qtd\'=> \CountHelper::count($result)'); $this->addLine(ESP.ESP.ESP.ESP.ESP.', \'result\'=>$result'); diff --git a/system_skeleton/rest/api/api_controllers/TGenericAPI.class.php b/system_skeleton/rest/api/api_controllers/TGenericAPI.class.php index 419c15e..39609e7 100644 --- a/system_skeleton/rest/api/api_controllers/TGenericAPI.class.php +++ b/system_skeleton/rest/api/api_controllers/TGenericAPI.class.php @@ -16,4 +16,15 @@ public static function getBodyJson($msg, Response $response) $response->getBody()->write( $msgJson ); return $response->withHeader('Content-Type', 'application/json'); } + public static function getSelectNumPage($args) + { + $page = \ArrayHelper::get($args,'page'); + return $page; + } + public static function getSelectNumRowsPerPage($args) + { + $rowsPerPage = \ArrayHelper::get($args,'rowsPerPage'); + $rowsPerPage = empty($page)?ROWS_PER_PAGE:$rowsPerPage; + return $rowsPerPage; + } } \ No newline at end of file