export feature

This commit is contained in:
2026-05-09 20:51:29 +02:00
parent 1eaa3ca8a6
commit dcfc17f542
57 changed files with 2245 additions and 624 deletions

View File

@@ -1,23 +1,13 @@
use std::sync::Arc;
use domain::{errors::DomainError, value_objects::UserId};
use domain::{
errors::DomainError,
ports::{DiaryExporter, DiaryRepository},
};
use crate::{commands::ExportCommand, context::AppContext};
use crate::commands::ExportCommand;
pub struct ExportDiary {
repository: Arc<dyn DiaryRepository>,
exporter: Arc<dyn DiaryExporter>,
}
impl ExportDiary {
pub async fn execute(&self, req: ExportCommand) -> Result<Vec<u8>, DomainError> {
// 1. fetch all diary entries for the user
// 2. delegate serialization to the port (exporter)
// Return bytes of the exported diary, which can be written to a file or returned in an HTTP response
Ok(vec![])
}
pub async fn execute(ctx: &AppContext, cmd: ExportCommand) -> Result<Vec<u8>, DomainError> {
let entries = ctx
.diary_repository
.get_user_history(&UserId::from_uuid(cmd.user_id))
.await?;
ctx.diary_exporter
.serialize_entries(&entries, cmd.format)
.await
}