style: cargo fmt --all
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
use domain::{
|
||||
entities::Album,
|
||||
errors::DomainError,
|
||||
ports::AlbumRepository,
|
||||
value_objects::SystemId,
|
||||
entities::Album, errors::DomainError, ports::AlbumRepository, value_objects::SystemId,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct CreateAlbumCommand {
|
||||
@@ -23,7 +20,9 @@ impl CreateAlbumHandler {
|
||||
|
||||
pub async fn execute(&self, cmd: CreateAlbumCommand) -> Result<Album, DomainError> {
|
||||
if cmd.title.is_empty() {
|
||||
return Err(DomainError::Validation("Album title must not be empty".to_string()));
|
||||
return Err(DomainError::Validation(
|
||||
"Album title must not be empty".to_string(),
|
||||
));
|
||||
}
|
||||
let album = Album::new(&cmd.title, cmd.creator_id);
|
||||
self.album_repo.save(&album).await?;
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
use domain::{
|
||||
entities::Album,
|
||||
errors::DomainError,
|
||||
ports::AlbumRepository,
|
||||
value_objects::SystemId,
|
||||
entities::Album, errors::DomainError, ports::AlbumRepository, value_objects::SystemId,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub enum AlbumAction {
|
||||
@@ -29,7 +26,10 @@ impl ManageAlbumEntriesHandler {
|
||||
}
|
||||
|
||||
pub async fn execute(&self, cmd: ManageAlbumEntriesCommand) -> Result<Album, DomainError> {
|
||||
let mut album = self.album_repo.find_by_id(&cmd.album_id).await?
|
||||
let mut album = self
|
||||
.album_repo
|
||||
.find_by_id(&cmd.album_id)
|
||||
.await?
|
||||
.ok_or_else(|| DomainError::NotFound(format!("Album {} not found", cmd.album_id)))?;
|
||||
|
||||
match cmd.action {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use std::sync::Arc;
|
||||
use domain::{
|
||||
entities::{AssetTag, Tag},
|
||||
errors::DomainError,
|
||||
ports::{AssetRepository, TagRepository},
|
||||
value_objects::SystemId,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct TagAssetCommand {
|
||||
@@ -20,11 +20,16 @@ pub struct TagAssetHandler {
|
||||
|
||||
impl TagAssetHandler {
|
||||
pub fn new(asset_repo: Arc<dyn AssetRepository>, tag_repo: Arc<dyn TagRepository>) -> Self {
|
||||
Self { asset_repo, tag_repo }
|
||||
Self {
|
||||
asset_repo,
|
||||
tag_repo,
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn execute(&self, cmd: TagAssetCommand) -> Result<(Tag, AssetTag), DomainError> {
|
||||
self.asset_repo.find_by_id(&cmd.asset_id).await?
|
||||
self.asset_repo
|
||||
.find_by_id(&cmd.asset_id)
|
||||
.await?
|
||||
.ok_or_else(|| DomainError::NotFound(format!("Asset {} not found", cmd.asset_id)))?;
|
||||
|
||||
let tag = match self.tag_repo.find_by_name(&cmd.tag_name).await? {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
pub mod commands;
|
||||
pub mod queries;
|
||||
|
||||
pub use commands::{CreateAlbumCommand, CreateAlbumHandler};
|
||||
pub use commands::{AlbumAction, ManageAlbumEntriesCommand, ManageAlbumEntriesHandler};
|
||||
pub use commands::{CreateAlbumCommand, CreateAlbumHandler};
|
||||
pub use commands::{TagAssetCommand, TagAssetHandler};
|
||||
pub use queries::get_album::{GetAlbumQuery, GetAlbumHandler};
|
||||
pub use queries::get_album::{GetAlbumHandler, GetAlbumQuery};
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
use domain::{
|
||||
entities::Album,
|
||||
errors::DomainError,
|
||||
ports::AlbumRepository,
|
||||
value_objects::SystemId,
|
||||
entities::Album, errors::DomainError, ports::AlbumRepository, value_objects::SystemId,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct GetAlbumQuery {
|
||||
@@ -21,7 +18,9 @@ impl GetAlbumHandler {
|
||||
}
|
||||
|
||||
pub async fn execute(&self, query: GetAlbumQuery) -> Result<Album, DomainError> {
|
||||
self.album_repo.find_by_id(&query.album_id).await?
|
||||
self.album_repo
|
||||
.find_by_id(&query.album_id)
|
||||
.await?
|
||||
.ok_or_else(|| DomainError::NotFound(format!("Album {} not found", query.album_id)))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user