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

@@ -1,5 +1,6 @@
#[derive(Debug, serde::Deserialize, utoipa::ToSchema)]
pub struct RegisterRequest {
pub username: String,
pub email: String,
pub password: String,
}
@@ -9,3 +10,8 @@ pub struct LoginRequest {
pub email: String,
pub password: String,
}
#[derive(Debug, serde::Deserialize, utoipa::ToSchema)]
pub struct CreateAlbumRequest {
pub title: String,
}

View File

@@ -4,6 +4,7 @@ use uuid::Uuid;
#[derive(Debug, serde::Serialize, utoipa::ToSchema)]
pub struct UserResponse {
pub id: Uuid,
pub username: String,
pub email: String,
pub created_at: DateTime<Utc>,
}
@@ -18,8 +19,30 @@ impl UserResponse {
pub fn from_domain(user: &domain::entities::User) -> Self {
Self {
id: *user.id.as_uuid(),
username: user.username.clone(),
email: user.email.to_string(),
created_at: user.created_at,
}
}
}
#[derive(Debug, serde::Serialize, utoipa::ToSchema)]
pub struct AlbumResponse {
pub id: Uuid,
pub title: String,
pub description: String,
pub creator_id: Uuid,
pub created_at: DateTime<Utc>,
}
impl AlbumResponse {
pub fn from_domain(album: &domain::entities::Album) -> Self {
Self {
id: *album.album_id.as_uuid(),
title: album.title.clone(),
description: album.description.clone(),
creator_id: *album.creator_user_id.as_uuid(),
created_at: *album.created_at.as_datetime(),
}
}
}