koprogo_api/application/ports/
vote_repository.rs1use crate::domain::entities::Vote;
2use async_trait::async_trait;
3use rust_decimal::Decimal;
4use uuid::Uuid;
5
6#[async_trait]
8pub trait VoteRepository: Send + Sync {
9 async fn create(&self, vote: &Vote) -> Result<Vote, String>;
11
12 async fn find_by_id(&self, id: Uuid) -> Result<Option<Vote>, String>;
14
15 async fn find_by_resolution_id(&self, resolution_id: Uuid) -> Result<Vec<Vote>, String>;
17
18 async fn find_by_owner_id(&self, owner_id: Uuid) -> Result<Vec<Vote>, String>;
20
21 async fn find_by_resolution_and_unit(
23 &self,
24 resolution_id: Uuid,
25 unit_id: Uuid,
26 ) -> Result<Option<Vote>, String>;
27
28 async fn has_voted(&self, resolution_id: Uuid, unit_id: Uuid) -> Result<bool, String>;
30
31 async fn update(&self, vote: &Vote) -> Result<Vote, String>;
33
34 async fn delete(&self, id: Uuid) -> Result<bool, String>;
36
37 async fn count_by_resolution_and_choice(
39 &self,
40 resolution_id: Uuid,
41 ) -> Result<(i32, i32, i32), String>; async fn sum_voting_power_by_resolution(
45 &self,
46 resolution_id: Uuid,
47 ) -> Result<(Decimal, Decimal, Decimal), String>; async fn count_proxy_votes_for_mandataire(
52 &self,
53 resolution_id: Uuid,
54 proxy_owner_id: Uuid,
55 ) -> Result<(i64, Decimal), String>;
56}