puerto 0.21.0

Puerto — Rust full-stack DDD framework CLI. Scaffolds Clean Architecture projects with auto-wired DI, SQLx support, and zero manual wiring. Formerly puerto-framework.
use dominio_{{ snake }}::modelo::{{ pascal }};
use poem_openapi::Object;
{% if is_crud %}use puerto_nucleo::Pagina;
{% endif %}use uuid::Uuid;{% for import in imports %}
use {{ import }};{% endfor %}

#[derive(Debug, Object)]
#[oai(rename_all = "camelCase")]
pub struct Dto{{ pascal }} {
    pub id: Uuid,
{% for f in fields %}    pub {{ f.name }}: {{ f.field_type }},
{% endfor %}}

impl Dto{{ pascal }} {
    pub fn from_dominio(entidad: &{{ pascal }}) -> Self {
        Self {
            id: entidad.id.valor(),
{% for f in fields %}            {{ f.name }}: {{ f.accessor }},
{% endfor %}        }
    }
}

#[derive(Debug, Object)]
#[oai(rename_all = "camelCase")]
pub struct PeticionCrear{{ pascal }} {
{% for f in fields %}    pub {{ f.name }}: {{ f.field_type }},
{% endfor %}}
{% if is_crud %}

/// Una página de {{ plural_pascal }}: `total` es el recuento completo y `limite`, el que aplicó
/// la API.
#[derive(Debug, Object)]
#[oai(rename_all = "camelCase")]
pub struct DtoPagina{{ pascal }} {
    pub elementos: Vec<Dto{{ pascal }}>,
    pub total: u64,
    pub limite: u32,
    pub desplazamiento: u32,
}

impl DtoPagina{{ pascal }} {
    pub fn from_dominio(pagina: &Pagina<{{ pascal }}>) -> Self {
        Self {
            elementos: pagina.elementos.iter().map(Dto{{ pascal }}::from_dominio).collect(),
            total: pagina.total,
            limite: pagina.limite,
            desplazamiento: pagina.desplazamiento,
        }
    }
}

#[derive(Debug, Object)]
#[oai(rename_all = "camelCase")]
pub struct PeticionActualizar{{ pascal }} {
{% for f in fields %}    pub {{ f.name }}: {{ f.field_type }},
{% endfor %}}
{% endif %}