koprogo_api/application/ports/
work_report_repository.rs

1use crate::application::dto::{PageRequest, WorkReportFilters};
2use crate::domain::entities::WorkReport;
3use async_trait::async_trait;
4use uuid::Uuid;
5
6#[async_trait]
7pub trait WorkReportRepository: Send + Sync {
8    async fn create(&self, work_report: &WorkReport) -> Result<WorkReport, String>;
9    async fn find_by_id(&self, id: Uuid) -> Result<Option<WorkReport>, String>;
10    async fn find_by_building(&self, building_id: Uuid) -> Result<Vec<WorkReport>, String>;
11    async fn find_by_organization(&self, organization_id: Uuid) -> Result<Vec<WorkReport>, String>;
12
13    /// Find all work reports with pagination and filters
14    /// Returns tuple of (work_reports, total_count)
15    async fn find_all_paginated(
16        &self,
17        page_request: &PageRequest,
18        filters: &WorkReportFilters,
19    ) -> Result<(Vec<WorkReport>, i64), String>;
20
21    /// Find work reports with active warranties
22    async fn find_with_active_warranty(&self, building_id: Uuid)
23        -> Result<Vec<WorkReport>, String>;
24
25    /// Find work reports with expiring warranties (within N days)
26    async fn find_with_expiring_warranty(
27        &self,
28        building_id: Uuid,
29        days: i32,
30    ) -> Result<Vec<WorkReport>, String>;
31
32    async fn update(&self, work_report: &WorkReport) -> Result<WorkReport, String>;
33    async fn delete(&self, id: Uuid) -> Result<bool, String>;
34}