diff options
author | crupest <crupest@outlook.com> | 2021-05-13 15:53:08 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-05-13 15:53:08 +0800 |
commit | 5b059ad031b87fc2e3beaf1b650fc365b34b86ba (patch) | |
tree | dd56141734ad3c97ae1a6c8e8a9b4f25ebabeca3 /BackEnd/Timeline/Controllers/TimelinePostController.cs | |
parent | aea8e41def7eab0d4e9f339ff14143f5441ae71d (diff) | |
download | timeline-5b059ad031b87fc2e3beaf1b650fc365b34b86ba.tar.gz timeline-5b059ad031b87fc2e3beaf1b650fc365b34b86ba.tar.bz2 timeline-5b059ad031b87fc2e3beaf1b650fc365b34b86ba.zip |
feat: Posts pagination.
Diffstat (limited to 'BackEnd/Timeline/Controllers/TimelinePostController.cs')
-rw-r--r-- | BackEnd/Timeline/Controllers/TimelinePostController.cs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/BackEnd/Timeline/Controllers/TimelinePostController.cs b/BackEnd/Timeline/Controllers/TimelinePostController.cs index 21d3821a..da45cbea 100644 --- a/BackEnd/Timeline/Controllers/TimelinePostController.cs +++ b/BackEnd/Timeline/Controllers/TimelinePostController.cs @@ -57,12 +57,14 @@ namespace Timeline.Controllers /// <param name="timeline">The name of the timeline.</param>
/// <param name="modifiedSince">If set, only posts modified since the time will return.</param>
/// <param name="includeDeleted">If set to true, deleted post will also return.</param>
+ /// <param name="page">Page number, starting from 0. Null to get all.</param>
+ /// <param name="numberPerPage">Post number per page. Default is 20.</param>
/// <returns>The post list.</returns>
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status403Forbidden)]
[ProducesResponseType(StatusCodes.Status404NotFound)]
- public async Task<ActionResult<List<HttpTimelinePost>>> List([FromRoute][GeneralTimelineName] string timeline, [FromQuery] DateTime? modifiedSince, [FromQuery] bool? includeDeleted)
+ public async Task<ActionResult<List<HttpTimelinePost>>> List([FromRoute][GeneralTimelineName] string timeline, [FromQuery] DateTime? modifiedSince, [FromQuery] bool? includeDeleted, [FromQuery][Range(0, int.MaxValue)] int? page, [FromQuery][Range(1, int.MaxValue)] int? numberPerPage)
{
var timelineId = await _timelineService.GetTimelineIdByNameAsync(timeline);
@@ -71,7 +73,7 @@ namespace Timeline.Controllers return ForbidWithCommonResponse();
}
- var posts = await _postService.GetPostsAsync(timelineId, modifiedSince, includeDeleted ?? false);
+ var posts = await _postService.GetPostsAsync(timelineId, modifiedSince, includeDeleted ?? false, page, numberPerPage);
var result = await Map(posts);
return result;
|