//! {{RESOURCE_NAME_PASCAL}} service
//!
//! Generated by: keg gen api {{RESOURCE_NAME}}
//!
//! Service layer with dependency injection. Controllers use this, not repositories.
use crate::internal::{
logic::{{RESOURCE_NAME}}_logic::{{RESOURCE_NAME_PASCAL}}Logic,
model::entity::{{RESOURCE_NAME_PASCAL}},
};
use anyhow::Result;
use uuid::Uuid;
/// Service for {{RESOURCE_NAME_PASCAL}} operations
#[derive(Clone)]
pub struct {{RESOURCE_NAME_PASCAL}}Service {
logic: {{RESOURCE_NAME_PASCAL}}Logic,
}
impl {{RESOURCE_NAME_PASCAL}}Service {
/// Create a new service (typically via AppState or a DI container)
pub fn new(logic: {{RESOURCE_NAME_PASCAL}}Logic) -> Self {
Self { logic }
}
/// List all {{RESOURCE_NAME_PASCAL}} items
pub async fn list() -> Result<Vec<{{RESOURCE_NAME_PASCAL}}>>
where
Self: Sized,
{
todo!("Initialize repository and logic to call list")
}
/// Get a single {{RESOURCE_NAME_PASCAL}} by ID
pub async fn get(id: Uuid) -> Result<Option<{{RESOURCE_NAME_PASCAL}}>>
where
Self: Sized,
{
todo!("Initialize repository and logic to call get")
}
/// Create a new {{RESOURCE_NAME_PASCAL}}
pub async fn create(name: &str) -> Result<{{RESOURCE_NAME_PASCAL}}>
where
Self: Sized,
{
todo!("Initialize repository and logic to call create")
}
/// Update a {{RESOURCE_NAME_PASCAL}}
pub async fn update(id: Uuid, name: Option<&str>) -> Result<{{RESOURCE_NAME_PASCAL}}>
where
Self: Sized,
{
todo!("Initialize repository and logic to call update")
}
/// Delete a {{RESOURCE_NAME_PASCAL}}
pub async fn delete(id: Uuid) -> Result<()>
where
Self: Sized,
{
todo!("Initialize repository and logic to call delete")
}
}