Initial commit

This commit is contained in:
root
2025-03-17 21:28:08 +01:00
commit fe19bc8505
58 changed files with 7202 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
use serde::Serialize;
use crate::domain::entities::file::File;
/// DTO for file responses
#[derive(Debug, Serialize)]
pub struct FileDto {
/// File ID
pub id: String,
/// File name
pub name: String,
/// Path to the file (relative)
pub path: String,
/// Size in bytes
pub size: u64,
/// MIME type
pub mime_type: String,
/// Parent folder ID
pub folder_id: Option<String>,
/// Creation timestamp
pub created_at: u64,
/// Last modification timestamp
pub modified_at: u64,
}
impl From<File> for FileDto {
fn from(file: File) -> Self {
Self {
id: file.id,
name: file.name,
path: file.path.to_string_lossy().to_string(),
size: file.size,
mime_type: file.mime_type,
folder_id: file.folder_id,
created_at: file.created_at,
modified_at: file.modified_at,
}
}
}
+66
View File
@@ -0,0 +1,66 @@
use serde::{Serialize, Deserialize};
use crate::domain::entities::folder::Folder;
/// DTO for folder creation requests
#[derive(Debug, Deserialize)]
pub struct CreateFolderDto {
/// Name of the folder to create
pub name: String,
/// Parent folder ID (None for root level)
pub parent_id: Option<String>,
}
/// DTO for folder rename requests
#[derive(Debug, Deserialize)]
pub struct RenameFolderDto {
/// New name for the folder
pub name: String,
}
/// DTO for folder move requests
#[derive(Debug, Deserialize)]
pub struct MoveFolderDto {
/// New parent folder ID (None for root level)
pub parent_id: Option<String>,
}
/// DTO for folder responses
#[derive(Debug, Serialize)]
pub struct FolderDto {
/// Folder ID
pub id: String,
/// Folder name
pub name: String,
/// Path to the folder (relative)
pub path: String,
/// Parent folder ID
pub parent_id: Option<String>,
/// Creation timestamp
pub created_at: u64,
/// Last modification timestamp
pub modified_at: u64,
/// Whether this is a root folder
pub is_root: bool,
}
impl From<Folder> for FolderDto {
fn from(folder: Folder) -> Self {
let is_root = folder.parent_id.is_none();
Self {
id: folder.id,
name: folder.name,
path: folder.path.to_string_lossy().to_string(),
parent_id: folder.parent_id,
created_at: folder.created_at,
modified_at: folder.modified_at,
is_root,
}
}
}
+62
View File
@@ -0,0 +1,62 @@
use serde::{Serialize, Deserialize};
use crate::domain::services::i18n_service::Locale;
/// DTO for locale information
#[derive(Debug, Serialize, Deserialize)]
pub struct LocaleDto {
/// Locale code (e.g., "en", "es")
pub code: String,
/// Locale name in its own language (e.g., "English", "Español")
pub name: String,
}
impl From<Locale> for LocaleDto {
fn from(locale: Locale) -> Self {
let (code, name) = match locale {
Locale::English => ("en", "English"),
Locale::Spanish => ("es", "Español"),
};
Self {
code: code.to_string(),
name: name.to_string(),
}
}
}
/// DTO for translation request
#[derive(Debug, Deserialize)]
pub struct TranslationRequestDto {
/// The translation key
pub key: String,
/// The locale code (optional, defaults to "en")
pub locale: Option<String>,
}
/// DTO for translation response
#[derive(Debug, Serialize)]
pub struct TranslationResponseDto {
/// The translation key
pub key: String,
/// The locale code used for translation
pub locale: String,
/// The translated text
pub text: String,
}
/// DTO for translation error
#[derive(Debug, Serialize)]
pub struct TranslationErrorDto {
/// The translation key that was not found
pub key: String,
/// The locale code used for translation
pub locale: String,
/// The error message
pub error: String,
}
+4
View File
@@ -0,0 +1,4 @@
pub mod file_dto;
pub mod folder_dto;
pub mod i18n_dto;