refactor: restructure application to CQRS, update api-types + presentation

- application: replace flat use_cases/ with identity/{commands,queries}/ and organization/commands/
- each use case now split into Command/Query struct + Handler struct
- api-types: add username to RegisterRequest/UserResponse, add CreateAlbumRequest/AlbumResponse
- presentation: update state, handlers, factory to use new handler types
- tests: restructured to match CQRS module layout, added get_profile tests
This commit is contained in:
2026-05-31 05:00:34 +02:00
parent d62d8157a8
commit fa36bb8c0e
43 changed files with 305 additions and 168 deletions

View File

@@ -0,0 +1,32 @@
use std::sync::Arc;
use domain::{
entities::Album,
errors::DomainError,
ports::AlbumRepository,
value_objects::SystemId,
};
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct CreateAlbumCommand {
pub title: String,
pub creator_id: SystemId,
}
pub struct CreateAlbumHandler {
album_repo: Arc<dyn AlbumRepository>,
}
impl CreateAlbumHandler {
pub fn new(album_repo: Arc<dyn AlbumRepository>) -> Self {
Self { album_repo }
}
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()));
}
let album = Album::new(&cmd.title, cmd.creator_id);
self.album_repo.save(&album).await?;
Ok(album)
}
}

View File

@@ -0,0 +1,3 @@
pub mod create_album;
pub use create_album::{CreateAlbumCommand, CreateAlbumHandler};

View File

@@ -0,0 +1,3 @@
pub mod commands;
pub use commands::{CreateAlbumCommand, CreateAlbumHandler};