feat: frontend-ready backend — pagination, auto-derivatives, list endpoints, bulk ops, OpenAPI

Pagination: count_by_owner + count_search on AssetRepository,
timeline/search return real total count (not page len).

Auto-derivatives: worker enqueues GenerateDerivative when
ExtractMetadata job completes, closing the upload→thumbnail gap.

List endpoints: GET /albums, GET /stacks with user scoping.
ListAlbumsHandler, ListStacksHandler, find_by_owner on AssetStackRepository.

Tag filtering: tag_name field on AssetFilters, JOIN asset_tags+tags
in postgres search/count queries.

Bulk operations: POST /assets/bulk-delete, POST /assets/bulk-tag.

Album update: PUT /albums/{id} with UpdateAlbumHandler (title, description).

OpenAPI: utoipa annotations on all 47 endpoints + all request/response
schemas registered. Scalar UI at /scalar covers full API.
This commit is contained in:
2026-05-31 23:06:25 +02:00
parent bcaf49cc81
commit 7b5bb66b37
33 changed files with 1048 additions and 72 deletions

View File

@@ -1,7 +1,9 @@
pub mod create_album;
pub mod manage_album_entries;
pub mod tag_asset;
pub mod update_album;
pub use create_album::{CreateAlbumCommand, CreateAlbumHandler};
pub use manage_album_entries::{AlbumAction, ManageAlbumEntriesCommand, ManageAlbumEntriesHandler};
pub use tag_asset::{TagAssetCommand, TagAssetHandler};
pub use update_album::{UpdateAlbumCommand, UpdateAlbumHandler};

View File

@@ -0,0 +1,44 @@
use domain::{errors::DomainError, ports::AlbumRepository, value_objects::SystemId};
use std::sync::Arc;
pub struct UpdateAlbumCommand {
pub album_id: SystemId,
pub user_id: SystemId,
pub title: Option<String>,
pub description: Option<String>,
}
pub struct UpdateAlbumHandler {
album_repo: Arc<dyn AlbumRepository>,
}
impl UpdateAlbumHandler {
pub fn new(album_repo: Arc<dyn AlbumRepository>) -> Self {
Self { album_repo }
}
pub async fn execute(
&self,
cmd: UpdateAlbumCommand,
) -> Result<domain::entities::Album, DomainError> {
let mut album = self
.album_repo
.find_by_id(&cmd.album_id)
.await?
.ok_or_else(|| DomainError::NotFound("Album not found".into()))?;
if album.creator_user_id != cmd.user_id {
return Err(DomainError::Forbidden("Not your album".into()));
}
if let Some(title) = cmd.title {
album.title = title;
}
if let Some(desc) = cmd.description {
album.description = desc;
}
self.album_repo.save(&album).await?;
Ok(album)
}
}

View File

@@ -4,4 +4,6 @@ pub mod queries;
pub use commands::{AlbumAction, ManageAlbumEntriesCommand, ManageAlbumEntriesHandler};
pub use commands::{CreateAlbumCommand, CreateAlbumHandler};
pub use commands::{TagAssetCommand, TagAssetHandler};
pub use commands::{UpdateAlbumCommand, UpdateAlbumHandler};
pub use queries::get_album::{GetAlbumHandler, GetAlbumQuery};
pub use queries::list_albums::{ListAlbumsHandler, ListAlbumsQuery};

View File

@@ -0,0 +1,22 @@
use domain::{
entities::Album, errors::DomainError, ports::AlbumRepository, value_objects::SystemId,
};
use std::sync::Arc;
pub struct ListAlbumsQuery {
pub user_id: SystemId,
}
pub struct ListAlbumsHandler {
album_repo: Arc<dyn AlbumRepository>,
}
impl ListAlbumsHandler {
pub fn new(album_repo: Arc<dyn AlbumRepository>) -> Self {
Self { album_repo }
}
pub async fn execute(&self, query: ListAlbumsQuery) -> Result<Vec<Album>, DomainError> {
self.album_repo.find_by_creator(&query.user_id).await
}
}

View File

@@ -1 +1,2 @@
pub mod get_album;
pub mod list_albums;