koprogo_api/application/ports/
contractor_report_repository.rs

1use crate::domain::entities::contractor_report::ContractorReport;
2use async_trait::async_trait;
3use uuid::Uuid;
4
5#[async_trait]
6pub trait ContractorReportRepository: Send + Sync {
7    /// Crée un nouveau rapport de travaux
8    async fn create(&self, report: &ContractorReport) -> Result<ContractorReport, String>;
9
10    /// Récupère un rapport par son ID
11    async fn find_by_id(&self, id: Uuid) -> Result<Option<ContractorReport>, String>;
12
13    /// Récupère un rapport via son magic token (accès PWA sans auth)
14    async fn find_by_magic_token(
15        &self,
16        token_hash: &str,
17    ) -> Result<Option<ContractorReport>, String>;
18
19    /// Liste les rapports d'un ticket donné
20    async fn find_by_ticket(&self, ticket_id: Uuid) -> Result<Vec<ContractorReport>, String>;
21
22    /// Liste les rapports d'un quote/devis donné
23    async fn find_by_quote(&self, quote_id: Uuid) -> Result<Vec<ContractorReport>, String>;
24
25    /// Liste tous les rapports d'un bâtiment
26    async fn find_by_building(&self, building_id: Uuid) -> Result<Vec<ContractorReport>, String>;
27
28    /// Liste tous les rapports d'une organisation
29    async fn find_by_organization(
30        &self,
31        organization_id: Uuid,
32    ) -> Result<Vec<ContractorReport>, String>;
33
34    /// Met à jour le rapport (status, photos, compte-rendu, etc.)
35    async fn update(&self, report: &ContractorReport) -> Result<ContractorReport, String>;
36
37    /// Supprime un rapport (Draft seulement)
38    async fn delete(&self, id: Uuid) -> Result<bool, String>;
39}