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