koprogo_api/application/ports/
resolution_repository.rs

1use crate::domain::entities::{Resolution, ResolutionStatus};
2use async_trait::async_trait;
3use uuid::Uuid;
4
5/// Port (trait) for Resolution repository operations
6#[async_trait]
7pub trait ResolutionRepository: Send + Sync {
8    /// Create a new resolution
9    async fn create(&self, resolution: &Resolution) -> Result<Resolution, String>;
10
11    /// Find a resolution by ID
12    async fn find_by_id(&self, id: Uuid) -> Result<Option<Resolution>, String>;
13
14    /// Find all resolutions for a meeting
15    async fn find_by_meeting_id(&self, meeting_id: Uuid) -> Result<Vec<Resolution>, String>;
16
17    /// Find resolutions by status
18    async fn find_by_status(&self, status: ResolutionStatus) -> Result<Vec<Resolution>, String>;
19
20    /// Update a resolution (for vote counts and status changes)
21    async fn update(&self, resolution: &Resolution) -> Result<Resolution, String>;
22
23    /// Delete a resolution
24    async fn delete(&self, id: Uuid) -> Result<bool, String>;
25
26    /// Update vote counts for a resolution
27    async fn update_vote_counts(
28        &self,
29        resolution_id: Uuid,
30        vote_count_pour: i32,
31        vote_count_contre: i32,
32        vote_count_abstention: i32,
33        total_voting_power_pour: f64,
34        total_voting_power_contre: f64,
35        total_voting_power_abstention: f64,
36    ) -> Result<(), String>;
37
38    /// Close voting on a resolution and set final status
39    async fn close_voting(
40        &self,
41        resolution_id: Uuid,
42        final_status: ResolutionStatus,
43    ) -> Result<(), String>;
44
45    /// Get vote summary for all resolutions in a meeting
46    async fn get_meeting_vote_summary(&self, meeting_id: Uuid) -> Result<Vec<Resolution>, String>;
47}