koprogo_api/application/ports/
convocation_repository.rs

1use crate::domain::entities::{Convocation, ConvocationStatus};
2use async_trait::async_trait;
3use chrono::{DateTime, Utc};
4use uuid::Uuid;
5
6#[async_trait]
7pub trait ConvocationRepository: Send + Sync {
8    /// Create a new convocation
9    async fn create(&self, convocation: &Convocation) -> Result<Convocation, String>;
10
11    /// Find convocation by ID
12    async fn find_by_id(&self, id: Uuid) -> Result<Option<Convocation>, String>;
13
14    /// Find convocation by meeting ID
15    async fn find_by_meeting_id(&self, meeting_id: Uuid) -> Result<Option<Convocation>, String>;
16
17    /// Find all convocations for a building
18    async fn find_by_building(&self, building_id: Uuid) -> Result<Vec<Convocation>, String>;
19
20    /// Find all convocations for an organization
21    async fn find_by_organization(&self, organization_id: Uuid)
22        -> Result<Vec<Convocation>, String>;
23
24    /// Find convocations by status
25    async fn find_by_status(
26        &self,
27        organization_id: Uuid,
28        status: ConvocationStatus,
29    ) -> Result<Vec<Convocation>, String>;
30
31    /// Find convocations scheduled to be sent (status = Scheduled and scheduled_send_date <= now)
32    async fn find_pending_scheduled(&self, now: DateTime<Utc>) -> Result<Vec<Convocation>, String>;
33
34    /// Find sent convocations that need reminder (sent but 3 days before meeting, reminder not sent yet)
35    async fn find_needing_reminder(&self, now: DateTime<Utc>) -> Result<Vec<Convocation>, String>;
36
37    /// Update convocation
38    async fn update(&self, convocation: &Convocation) -> Result<Convocation, String>;
39
40    /// Delete convocation
41    async fn delete(&self, id: Uuid) -> Result<bool, String>;
42
43    /// Count convocations by building
44    async fn count_by_building(&self, building_id: Uuid) -> Result<i64, String>;
45
46    /// Count convocations by status
47    async fn count_by_status(
48        &self,
49        organization_id: Uuid,
50        status: ConvocationStatus,
51    ) -> Result<i64, String>;
52}