148 lines
3.1 KiB
Rust
148 lines
3.1 KiB
Rust
use crate::models::{AlbumPermission, Media, MediaMetadata};
|
|
|
|
pub struct UploadMediaData<'a> {
|
|
pub owner_id: uuid::Uuid,
|
|
pub filename: String,
|
|
pub mime_type: String,
|
|
pub stream:
|
|
Box<dyn futures::Stream<Item = Result<bytes::Bytes, std::io::Error>> + Send + Unpin + 'a>,
|
|
}
|
|
|
|
pub struct CreateUserData<'a> {
|
|
pub username: &'a str,
|
|
pub email: &'a str,
|
|
pub password: &'a str,
|
|
}
|
|
|
|
pub struct LoginUserData<'a> {
|
|
pub username_or_email: &'a str,
|
|
pub password: &'a str,
|
|
}
|
|
|
|
pub struct CreateAlbumData<'a> {
|
|
pub owner_id: uuid::Uuid,
|
|
pub name: &'a str,
|
|
pub description: Option<&'a str>,
|
|
pub is_public: bool,
|
|
}
|
|
|
|
pub struct UpdateAlbumData<'a> {
|
|
pub name: Option<&'a str>,
|
|
pub description: Option<Option<&'a str>>,
|
|
pub is_public: Option<bool>,
|
|
}
|
|
|
|
pub struct AddMediaToAlbumData {
|
|
pub album_id: uuid::Uuid,
|
|
pub media_ids: Vec<uuid::Uuid>,
|
|
}
|
|
|
|
pub struct ShareAlbumData {
|
|
pub album_id: uuid::Uuid,
|
|
pub target_user_id: uuid::Uuid,
|
|
pub permission: AlbumPermission,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub enum SortOrder {
|
|
Asc,
|
|
Desc,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct SortParams {
|
|
pub sort_by: String,
|
|
pub sort_order: SortOrder,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Default)]
|
|
pub struct FilterParams {
|
|
pub mime_type: Option<String>,
|
|
pub metadata_filters: Option<Vec<MetadataFilter>>,
|
|
pub conditions: Option<Vec<FilterCondition>>,
|
|
// In the future, we can add fields like:
|
|
// pub date_range: Option<(chrono::DateTime<chrono::Utc>, chrono::DateTime<chrono::Utc>)>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
pub struct PaginationParams {
|
|
pub page: u32,
|
|
pub limit: u32,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct ListMediaOptions {
|
|
pub sort: Option<SortParams>,
|
|
pub filter: Option<FilterParams>,
|
|
pub pagination: Option<PaginationParams>,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct MetadataFilter {
|
|
pub tag_name: String,
|
|
pub tag_value: String,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub struct FilterCondition {
|
|
pub field: String,
|
|
pub operator: FilterOperator,
|
|
pub value: String,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
pub enum FilterOperator {
|
|
Eq,
|
|
Neq,
|
|
Like,
|
|
Gt,
|
|
Lt,
|
|
Gte,
|
|
Lte,
|
|
}
|
|
|
|
pub struct MediaImportBundle {
|
|
pub media_model: Media,
|
|
pub metadata_models: Vec<MediaMetadata>,
|
|
pub file_size: i64,
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
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,
|
|
}
|
|
|
|
impl<T> PaginatedResponse<T> {
|
|
pub fn new(data: Vec<T>, page: u32, limit: u32, total_items: i64) -> Self {
|
|
let total_pages = if limit == 0 {
|
|
0
|
|
} else {
|
|
(total_items as f64 / limit as f64).ceil() as u32
|
|
};
|
|
|
|
let has_next_page = page < total_pages;
|
|
let has_prev_page = page > 1;
|
|
|
|
Self {
|
|
data,
|
|
page,
|
|
limit,
|
|
total_items,
|
|
total_pages,
|
|
has_next_page,
|
|
has_prev_page,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(serde::Deserialize)]
|
|
pub struct RemoveMediaFromAlbumRequest {
|
|
pub media_ids: Vec<uuid::Uuid>,
|
|
}
|