koprogo_api/application/ports/
technical_inspection_repository.rs

1use crate::application::dto::{PageRequest, TechnicalInspectionFilters};
2use crate::domain::entities::TechnicalInspection;
3use async_trait::async_trait;
4use uuid::Uuid;
5
6#[async_trait]
7pub trait TechnicalInspectionRepository: Send + Sync {
8    async fn create(&self, inspection: &TechnicalInspection)
9        -> Result<TechnicalInspection, String>;
10    async fn find_by_id(&self, id: Uuid) -> Result<Option<TechnicalInspection>, String>;
11    async fn find_by_building(&self, building_id: Uuid)
12        -> Result<Vec<TechnicalInspection>, String>;
13    async fn find_by_organization(
14        &self,
15        organization_id: Uuid,
16    ) -> Result<Vec<TechnicalInspection>, String>;
17
18    /// Find all technical inspections with pagination and filters
19    /// Returns tuple of (inspections, total_count)
20    async fn find_all_paginated(
21        &self,
22        page_request: &PageRequest,
23        filters: &TechnicalInspectionFilters,
24    ) -> Result<(Vec<TechnicalInspection>, i64), String>;
25
26    /// Find overdue inspections for a building
27    async fn find_overdue(&self, building_id: Uuid) -> Result<Vec<TechnicalInspection>, String>;
28
29    /// Find upcoming inspections (due within N days)
30    async fn find_upcoming(
31        &self,
32        building_id: Uuid,
33        days: i32,
34    ) -> Result<Vec<TechnicalInspection>, String>;
35
36    /// Find inspections by type for a building
37    async fn find_by_type(
38        &self,
39        building_id: Uuid,
40        inspection_type: &str,
41    ) -> Result<Vec<TechnicalInspection>, String>;
42
43    async fn update(&self, inspection: &TechnicalInspection)
44        -> Result<TechnicalInspection, String>;
45    async fn delete(&self, id: Uuid) -> Result<bool, String>;
46}