Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
SAMBUMBA
pasteque-server
Commits
e831b272
Commit
e831b272
authored
Feb 20, 2018
by
Karamel
Browse files
Add pagination to /api/ticket/search route.
parent
e60cf647
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/http/routes/ticket.php
View file @
e831b272
...
...
@@ -46,6 +46,16 @@ $app->GET('/api/ticket/search', function ($request, $response, $args) {
:
$queryParams
[
'user'
];
$customerId
=
(
empty
(
$queryParams
[
'customer'
]))
?
null
:
$queryParams
[
'customer'
];
$offset
=
(
empty
(
$queryParams
[
'offset'
]))
?
null
:
intval
(
$queryParams
[
'offset'
]);
if
(
$offset
===
0
)
{
$offset
=
null
;
}
$limit
=
(
empty
(
$queryParams
[
'limit'
]))
?
null
:
intval
(
$queryParams
[
'limit'
]);
if
(
$limit
===
0
)
{
$limit
=
null
;
}
// Search criterias
if
(
$dateStart
===
false
)
{
return
$response
->
withApiResult
(
APIResult
::
reject
(
'Invalid dateStart'
));
...
...
@@ -102,7 +112,12 @@ $app->GET('/api/ticket/search', function ($request, $response, $args) {
if
(
$customer
!==
null
)
{
$conditions
[]
=
new
DAOCondition
(
'customer'
,
'='
,
$customer
);
}
$tktRes
=
APICaller
::
run
(
$ptApp
,
'ticket'
,
'search'
,
[
$conditions
]);
if
(
!
empty
(
$queryParams
[
'count'
]))
{
$tktRes
=
APICaller
::
run
(
$ptApp
,
'ticket'
,
'count'
,
[
$conditions
]);
}
else
{
$tktRes
=
APICaller
::
run
(
$ptApp
,
'ticket'
,
'search'
,
[
$conditions
,
$limit
,
$offset
]);
}
return
$response
->
withApiResult
(
$tktRes
);
});
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment