init
This commit is contained in:
31
libertas_core/src/repositories.rs
Normal file
31
libertas_core/src/repositories.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use async_trait::async_trait;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
error::CoreResult,
|
||||
models::{Album, Media, User},
|
||||
};
|
||||
|
||||
#[async_trait]
|
||||
pub trait MediaRepository: Send + Sync {
|
||||
async fn find_by_hash(&self, hash: &str) -> CoreResult<Option<Media>>;
|
||||
async fn create(&self, media: &Media) -> CoreResult<()>;
|
||||
async fn find_by_id(&self, id: Uuid) -> CoreResult<Option<Media>>;
|
||||
async fn list_by_user(&self, user_id: Uuid) -> CoreResult<Vec<Media>>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait UserRepository: Send + Sync {
|
||||
async fn create(&self, user: User) -> CoreResult<()>;
|
||||
async fn find_by_email(&self, email: &str) -> CoreResult<Option<User>>;
|
||||
async fn find_by_username(&self, username: &str) -> CoreResult<Option<User>>;
|
||||
async fn find_by_id(&self, id: Uuid) -> CoreResult<Option<User>>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait AlbumRepository: Send + Sync {
|
||||
async fn create(&self, album: Album) -> CoreResult<()>;
|
||||
async fn find_by_id(&self, id: Uuid) -> CoreResult<Option<Album>>;
|
||||
async fn list_by_user(&self, user_id: Uuid) -> CoreResult<Vec<Album>>;
|
||||
async fn add_media_to_album(&self, album_id: Uuid, media_ids: &[Uuid]) -> CoreResult<()>;
|
||||
}
|
||||
Reference in New Issue
Block a user