feat: Implement pagination for user media retrieval and update related structures
This commit is contained in:
@@ -2,6 +2,7 @@ use libertas_core::models::{
|
||||
Album, AlbumPermission, FaceRegion, Media, MediaBundle, MediaMetadata, Person,
|
||||
PersonPermission, Tag,
|
||||
};
|
||||
use libertas_core::schema::PaginatedResponse as CorePaginatedResponse;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -246,3 +247,29 @@ pub struct PublicAlbumBundleResponse {
|
||||
pub struct MergePersonRequest {
|
||||
pub source_person_id: Uuid,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct PaginatedResponse<T> {
|
||||
pub data: Vec<T>,
|
||||
pub page: u32,
|
||||
pub limit: u32,
|
||||
pub total_items: i64,
|
||||
pub total_pages: u32,
|
||||
pub has_next_page: bool,
|
||||
pub has_prev_page: bool,
|
||||
}
|
||||
|
||||
pub fn map_paginated_response<T, U>(core_response: CorePaginatedResponse<T>) -> PaginatedResponse<U>
|
||||
where
|
||||
U: From<T>,
|
||||
{
|
||||
PaginatedResponse {
|
||||
data: core_response.data.into_iter().map(U::from).collect(),
|
||||
page: core_response.page,
|
||||
limit: core_response.limit,
|
||||
total_items: core_response.total_items,
|
||||
total_pages: core_response.total_pages,
|
||||
has_next_page: core_response.has_next_page,
|
||||
has_prev_page: core_response.has_prev_page,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user