use std::sync::Arc;
use anyhow::{Result, anyhow};
use async_trait::async_trait;
use uuid::Uuid;
use super::UseCase;
use crate::infrastructure::persistence::ConversionJobRepository;
#[derive(Debug, Clone)]
pub struct DeleteConversionJobInput {
pub id: Uuid,
}
#[derive(Debug, Clone)]
pub struct DeleteConversionJobOutput {
pub deleted: bool,
}
pub struct DeleteConversionJobUseCase {
repository: Arc<ConversionJobRepository>,
}
impl DeleteConversionJobUseCase {
pub fn new(repository: Arc<ConversionJobRepository>) -> Self {
Self { repository }
}
}
#[async_trait]
impl UseCase for DeleteConversionJobUseCase {
type Input = DeleteConversionJobInput;
type Output = DeleteConversionJobOutput;
async fn execute(&self, input: Self::Input) -> Result<Self::Output> {
let _ = self.repository.find_by_id(input.id).await?
.ok_or_else(|| anyhow!("ConversionJob not found"))?;
self.repository.delete(input.id).await?;
Ok(DeleteConversionJobOutput { deleted: true })
}
}