koprogo_api/application/ports/
notice_repository.rs1use crate::domain::entities::{Notice, NoticeCategory, NoticeStatus, NoticeType};
2use async_trait::async_trait;
3use uuid::Uuid;
4
5#[async_trait]
7pub trait NoticeRepository: Send + Sync {
8 async fn create(&self, notice: &Notice) -> Result<Notice, String>;
10
11 async fn find_by_id(&self, id: Uuid) -> Result<Option<Notice>, String>;
13
14 async fn find_by_building(&self, building_id: Uuid) -> Result<Vec<Notice>, String>;
16
17 async fn find_published_by_building(&self, building_id: Uuid) -> Result<Vec<Notice>, String>;
19
20 async fn find_pinned_by_building(&self, building_id: Uuid) -> Result<Vec<Notice>, String>;
22
23 async fn find_by_type(
25 &self,
26 building_id: Uuid,
27 notice_type: NoticeType,
28 ) -> Result<Vec<Notice>, String>;
29
30 async fn find_by_category(
32 &self,
33 building_id: Uuid,
34 category: NoticeCategory,
35 ) -> Result<Vec<Notice>, String>;
36
37 async fn find_by_status(
39 &self,
40 building_id: Uuid,
41 status: NoticeStatus,
42 ) -> Result<Vec<Notice>, String>;
43
44 async fn find_by_author(&self, author_id: Uuid) -> Result<Vec<Notice>, String>;
46
47 async fn find_expired(&self, building_id: Uuid) -> Result<Vec<Notice>, String>;
49
50 async fn update(&self, notice: &Notice) -> Result<Notice, String>;
52
53 async fn delete(&self, id: Uuid) -> Result<(), String>;
55
56 async fn count_by_building(&self, building_id: Uuid) -> Result<i64, String>;
58
59 async fn count_published_by_building(&self, building_id: Uuid) -> Result<i64, String>;
61
62 async fn count_pinned_by_building(&self, building_id: Uuid) -> Result<i64, String>;
64}