backbone-events 0.4.0

Events core + the sale/booth/crm/sms/desk overlay — registrations under one authoritative seat counter, the sale seam (order-minted registrations, forward-only paid heal, SO-cancel mirror cascade), booth bookings with the DB exclusivity wall, closed-vocabulary lead rules through a host sink port, the dual-channel (mail/sms) self-arming scheduler, and the exact-match desk verb (Odoo event port, core + overlay)
//! Repository for LeadRequest entities
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! Thin newtype over `backbone_orm::GenericCrudRepository<LeadRequest, backbone_orm::SoftDelete>`.
//! All standard CRUD methods are available via `Deref`.

use anyhow::Result;
use sqlx::PgPool;
use uuid::Uuid;

use crate::domain::entity::LeadRequest;

/// Table name for LeadRequest entities
pub const TABLE_NAME: &str = "event.lead_requests";

/// Repository for LeadRequest entities.
///
/// All standard CRUD, soft-delete, pagination, and bulk methods are
/// provided automatically via `Deref` to `backbone_orm::GenericCrudRepository`.
pub struct LeadRequestRepository(
    backbone_orm::GenericCrudRepository<LeadRequest, backbone_orm::SoftDelete>,
);

impl std::ops::Deref for LeadRequestRepository {
    type Target = backbone_orm::GenericCrudRepository<LeadRequest, backbone_orm::SoftDelete>;
    fn deref(&self) -> &Self::Target { &self.0 }
}

impl LeadRequestRepository {
    /// Create a new repository instance.
    pub fn new(pool: PgPool) -> Self {
        Self(backbone_orm::GenericCrudRepository::new(pool, TABLE_NAME))
    }
}

impl LeadRequestRepository {
    /// Find lead_request by event_id (excludes soft-deleted)
    pub async fn find_by_event_id(&self, event_id: uuid::Uuid) -> Result<Option<LeadRequest>> {
        self.find_by_uuid_field("event_id", event_id).await
    }

    /// Check if lead_request exists by event_id (excludes soft-deleted)
    pub async fn exists_by_event_id(&self, event_id: uuid::Uuid) -> Result<bool> {
        self.exists_by_uuid_field("event_id", event_id).await
    }

}

backbone_core::impl_crud_repository!(LeadRequestRepository, LeadRequest, soft_delete);