koprogo_api/application/ports/
etat_date_repository.rs1use crate::application::dto::etat_date_dto::EtatDateStatsResponse;
2use crate::application::dto::PageRequest;
3use crate::domain::entities::{EtatDate, EtatDateStatus};
4use async_trait::async_trait;
5use uuid::Uuid;
6
7#[async_trait]
8pub trait EtatDateRepository: Send + Sync {
9 async fn create(&self, etat_date: &EtatDate) -> Result<EtatDate, String>;
11
12 async fn find_by_id(&self, id: Uuid) -> Result<Option<EtatDate>, String>;
14
15 async fn find_by_reference_number(
17 &self,
18 reference_number: &str,
19 ) -> Result<Option<EtatDate>, String>;
20
21 async fn find_by_unit(&self, unit_id: Uuid) -> Result<Vec<EtatDate>, String>;
23
24 async fn find_by_building(&self, building_id: Uuid) -> Result<Vec<EtatDate>, String>;
26
27 async fn find_all_paginated(
29 &self,
30 page_request: &PageRequest,
31 organization_id: Option<Uuid>,
32 status: Option<EtatDateStatus>,
33 ) -> Result<(Vec<EtatDate>, i64), String>;
34
35 async fn find_overdue(&self, organization_id: Uuid) -> Result<Vec<EtatDate>, String>;
37
38 async fn find_expired(&self, organization_id: Uuid) -> Result<Vec<EtatDate>, String>;
40
41 async fn update(&self, etat_date: &EtatDate) -> Result<EtatDate, String>;
43
44 async fn delete(&self, id: Uuid) -> Result<bool, String>;
46
47 async fn get_stats(&self, organization_id: Uuid) -> Result<EtatDateStatsResponse, String>;
49
50 async fn count_by_status(
52 &self,
53 organization_id: Uuid,
54 status: EtatDateStatus,
55 ) -> Result<i64, String>;
56}