configuring backend topology

This commit is contained in:
DioCrafts
2025-03-28 12:38:48 +01:00
parent da520db0b3
commit 3a4cb75ac7
21 changed files with 2048 additions and 103 deletions
+1
View File
@@ -2,4 +2,5 @@ pub mod file_repository;
pub mod folder_repository;
pub mod user_repository;
pub mod session_repository;
pub mod share_repository;
pub mod trash_repository;
@@ -0,0 +1,47 @@
use std::sync::Arc;
use async_trait::async_trait;
use thiserror::Error;
use crate::domain::{
entities::share::{Share, ShareItemType},
repositories::user_repository::UserRepositoryError,
};
#[derive(Debug, Error)]
pub enum ShareRepositoryError {
#[error("Share not found: {0}")]
NotFound(String),
#[error("Item not found: {0}")]
ItemNotFound(String),
#[error("Storage error: {0}")]
StorageError(String),
#[error("User repository error: {0}")]
UserRepository(#[from] UserRepositoryError),
#[error("Share already exists: {0}")]
AlreadyExists(String),
}
#[async_trait]
pub trait ShareRepository: Send + Sync + 'static {
/// Save a new share or update an existing one
async fn save(&self, share: &Share) -> Result<Share, ShareRepositoryError>;
/// Find a share by its ID
async fn find_by_id(&self, id: &str) -> Result<Share, ShareRepositoryError>;
/// Find a share by its token
async fn find_by_token(&self, token: &str) -> Result<Share, ShareRepositoryError>;
/// Find all shares for a specific item
async fn find_by_item(&self, item_id: &str, item_type: &ShareItemType) -> Result<Vec<Share>, ShareRepositoryError>;
/// Delete a share by its ID
async fn delete(&self, id: &str) -> Result<(), ShareRepositoryError>;
/// Find all shares created by a specific user
async fn find_by_user(&self, user_id: &str) -> Result<Vec<Share>, ShareRepositoryError>;
/// Find all shares (admin operation)
async fn find_all(&self) -> Result<Vec<Share>, ShareRepositoryError>;
}