koprogo_api/application/ports/
shared_object_repository.rs1use crate::domain::entities::{SharedObject, SharedObjectCategory};
2use async_trait::async_trait;
3use uuid::Uuid;
4
5#[async_trait]
7pub trait SharedObjectRepository: Send + Sync {
8 async fn create(&self, object: &SharedObject) -> Result<SharedObject, String>;
10
11 async fn find_by_id(&self, id: Uuid) -> Result<Option<SharedObject>, String>;
13
14 async fn find_by_building(&self, building_id: Uuid) -> Result<Vec<SharedObject>, String>;
16
17 async fn find_available_by_building(
19 &self,
20 building_id: Uuid,
21 ) -> Result<Vec<SharedObject>, String>;
22
23 async fn find_borrowed_by_building(
25 &self,
26 building_id: Uuid,
27 ) -> Result<Vec<SharedObject>, String>;
28
29 async fn find_overdue_by_building(
31 &self,
32 building_id: Uuid,
33 ) -> Result<Vec<SharedObject>, String>;
34
35 async fn find_by_owner(&self, owner_id: Uuid) -> Result<Vec<SharedObject>, String>;
37
38 async fn find_borrowed_by_user(&self, borrower_id: Uuid) -> Result<Vec<SharedObject>, String>;
40
41 async fn find_by_category(
43 &self,
44 building_id: Uuid,
45 category: SharedObjectCategory,
46 ) -> Result<Vec<SharedObject>, String>;
47
48 async fn find_free_by_building(&self, building_id: Uuid) -> Result<Vec<SharedObject>, String>;
50
51 async fn update(&self, object: &SharedObject) -> Result<SharedObject, String>;
53
54 async fn delete(&self, id: Uuid) -> Result<(), String>;
56
57 async fn count_by_building(&self, building_id: Uuid) -> Result<i64, String>;
59
60 async fn count_available_by_building(&self, building_id: Uuid) -> Result<i64, String>;
62
63 async fn count_borrowed_by_building(&self, building_id: Uuid) -> Result<i64, String>;
65
66 async fn count_overdue_by_building(&self, building_id: Uuid) -> Result<i64, String>;
68
69 async fn count_by_category(
71 &self,
72 building_id: Uuid,
73 category: SharedObjectCategory,
74 ) -> Result<i64, String>;
75}