mirror of
https://github.com/grocy/grocy.git
synced 2026-04-07 05:16:15 +02:00
Use FilteredApiResponse for Generic-Entity-Search
This commit is contained in:
parent
84f519c5f4
commit
5c82fe14ca
|
|
@ -3,6 +3,7 @@
|
||||||
namespace Grocy\Controllers;
|
namespace Grocy\Controllers;
|
||||||
|
|
||||||
use Grocy\Controllers\Users\User;
|
use Grocy\Controllers\Users\User;
|
||||||
|
use Slim\Exception\HttpBadRequestException;
|
||||||
|
|
||||||
class GenericEntityApiController extends BaseApiController
|
class GenericEntityApiController extends BaseApiController
|
||||||
{
|
{
|
||||||
|
|
@ -178,12 +179,13 @@ class GenericEntityApiController extends BaseApiController
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return $this->ApiResponse($response, $this->getDatabase()->{$args['entity']}
|
return $this->FilteredApiResponse($response, $this->getDatabase()->{$args['entity']}
|
||||||
()->where('name LIKE ?', '%' . $args['searchString'] . '%'));
|
()->where('name LIKE ?', '%' . $args['searchString'] . '%'), $request->getQueryParams());
|
||||||
}
|
}
|
||||||
catch (\PDOException $ex)
|
catch (\PDOException $ex)
|
||||||
{
|
{
|
||||||
return $this->GenericErrorResponse($response, 'The given entity has no field "name"');
|
throw new HttpBadRequestException($request, $ex->getMessage(), $ex);
|
||||||
|
//return $this->GenericErrorResponse($response, 'The given entity has no field "name"', $ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ $app->group('/api', function(RouteCollectorProxy $group)
|
||||||
// Generic entity interaction
|
// Generic entity interaction
|
||||||
$group->get('/objects/{entity}', '\Grocy\Controllers\GenericEntityApiController:GetObjects');
|
$group->get('/objects/{entity}', '\Grocy\Controllers\GenericEntityApiController:GetObjects');
|
||||||
$group->get('/objects/{entity}/{objectId}', '\Grocy\Controllers\GenericEntityApiController:GetObject');
|
$group->get('/objects/{entity}/{objectId}', '\Grocy\Controllers\GenericEntityApiController:GetObject');
|
||||||
$group->get('/objects/{entity}/search/{searchString}', '\Grocy\Controllers\GenericEntityApiController:SearchObjects');
|
$group->get('/objects/{entity}/search/{searchString:.*}', '\Grocy\Controllers\GenericEntityApiController:SearchObjects');
|
||||||
$group->post('/objects/{entity}', '\Grocy\Controllers\GenericEntityApiController:AddObject');
|
$group->post('/objects/{entity}', '\Grocy\Controllers\GenericEntityApiController:AddObject');
|
||||||
$group->put('/objects/{entity}/{objectId}', '\Grocy\Controllers\GenericEntityApiController:EditObject');
|
$group->put('/objects/{entity}/{objectId}', '\Grocy\Controllers\GenericEntityApiController:EditObject');
|
||||||
$group->delete('/objects/{entity}/{objectId}', '\Grocy\Controllers\GenericEntityApiController:DeleteObject');
|
$group->delete('/objects/{entity}/{objectId}', '\Grocy\Controllers\GenericEntityApiController:DeleteObject');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user