koprogo_api/application/ports/
unit_owner_repository.rs1use crate::domain::entities::UnitOwner;
2use async_trait::async_trait;
3use uuid::Uuid;
4
5#[async_trait]
6pub trait UnitOwnerRepository: Send + Sync {
7 async fn create(&self, unit_owner: &UnitOwner) -> Result<UnitOwner, String>;
9
10 async fn find_by_id(&self, id: Uuid) -> Result<Option<UnitOwner>, String>;
12
13 async fn find_current_owners_by_unit(&self, unit_id: Uuid) -> Result<Vec<UnitOwner>, String>;
15
16 async fn find_current_units_by_owner(&self, owner_id: Uuid) -> Result<Vec<UnitOwner>, String>;
18
19 async fn find_all_owners_by_unit(&self, unit_id: Uuid) -> Result<Vec<UnitOwner>, String>;
21
22 async fn find_all_units_by_owner(&self, owner_id: Uuid) -> Result<Vec<UnitOwner>, String>;
24
25 async fn update(&self, unit_owner: &UnitOwner) -> Result<UnitOwner, String>;
27
28 async fn delete(&self, id: Uuid) -> Result<(), String>;
30
31 async fn has_active_owners(&self, unit_id: Uuid) -> Result<bool, String>;
33
34 async fn get_total_ownership_percentage(&self, unit_id: Uuid) -> Result<f64, String>;
36
37 async fn find_active_by_unit_and_owner(
39 &self,
40 unit_id: Uuid,
41 owner_id: Uuid,
42 ) -> Result<Option<UnitOwner>, String>;
43
44 async fn find_active_by_building(
48 &self,
49 building_id: Uuid,
50 ) -> Result<Vec<(Uuid, Uuid, f64)>, String>;
51}