koprogo_api/application/ports/
owner_repository.rs

1use crate::application::dto::{OwnerFilters, PageRequest};
2use crate::domain::entities::Owner;
3use async_trait::async_trait;
4use uuid::Uuid;
5
6#[async_trait]
7pub trait OwnerRepository: Send + Sync {
8    async fn create(&self, owner: &Owner) -> Result<Owner, String>;
9    async fn find_by_id(&self, id: Uuid) -> Result<Option<Owner>, String>;
10    async fn find_by_user_id(&self, user_id: Uuid) -> Result<Option<Owner>, String>;
11    async fn find_by_user_id_and_organization(
12        &self,
13        user_id: Uuid,
14        organization_id: Uuid,
15    ) -> Result<Option<Owner>, String>;
16    async fn find_by_email(&self, email: &str) -> Result<Option<Owner>, String>;
17    async fn find_all(&self) -> Result<Vec<Owner>, String>;
18
19    /// Find all owners with pagination and filters
20    /// Returns tuple of (owners, total_count)
21    async fn find_all_paginated(
22        &self,
23        page_request: &PageRequest,
24        filters: &OwnerFilters,
25    ) -> Result<(Vec<Owner>, i64), String>;
26
27    async fn update(&self, owner: &Owner) -> Result<Owner, String>;
28    async fn delete(&self, id: Uuid) -> Result<bool, String>;
29}