xecute-cli 0.1.21

Project and resource scaffolding for Axum applications with Xecute tools
//! Business operations backed by the injected repository.

use super::{
    dto::Create__TYPE__Dto,
    entity::__TYPE__,
    repository::{__TYPE__Repository, CapacityExceeded},
};
use std::sync::Arc;
use xecute::injectable;

/// Singleton service resolved automatically by the module container.
#[injectable]
pub struct __TYPE__Service {
    repository: Arc<__TYPE__Repository>,
}

impl __TYPE__Service {
    /// Retrieve the current collection.
    pub async fn list(&self) -> Vec<__TYPE__> {
        self.repository.list().await
    }
    /// Persist a payload that has already passed controller validation.
    pub async fn create(&self, payload: Create__TYPE__Dto) -> Result<__TYPE__, CapacityExceeded> {
        self.repository.create(payload.name.trim().to_owned()).await
    }
}