koprogo_api/application/ports/
skill_repository.rs

1use crate::domain::entities::{ExpertiseLevel, Skill, SkillCategory};
2use async_trait::async_trait;
3use uuid::Uuid;
4
5/// Repository port for Skill aggregate
6#[async_trait]
7pub trait SkillRepository: Send + Sync {
8    /// Create a new skill
9    async fn create(&self, skill: &Skill) -> Result<Skill, String>;
10
11    /// Find skill by ID
12    async fn find_by_id(&self, id: Uuid) -> Result<Option<Skill>, String>;
13
14    /// Find all skills for a building
15    async fn find_by_building(&self, building_id: Uuid) -> Result<Vec<Skill>, String>;
16
17    /// Find all available skills for a building (is_available_for_help = true)
18    async fn find_available_by_building(&self, building_id: Uuid) -> Result<Vec<Skill>, String>;
19
20    /// Find all skills by owner
21    async fn find_by_owner(&self, owner_id: Uuid) -> Result<Vec<Skill>, String>;
22
23    /// Find skills by category (HomeRepair, Languages, Technology, etc.)
24    async fn find_by_category(
25        &self,
26        building_id: Uuid,
27        category: SkillCategory,
28    ) -> Result<Vec<Skill>, String>;
29
30    /// Find skills by expertise level (Beginner, Intermediate, Advanced, Expert)
31    async fn find_by_expertise(
32        &self,
33        building_id: Uuid,
34        level: ExpertiseLevel,
35    ) -> Result<Vec<Skill>, String>;
36
37    /// Find free/volunteer skills for a building (hourly_rate_credits IS NULL OR = 0)
38    async fn find_free_by_building(&self, building_id: Uuid) -> Result<Vec<Skill>, String>;
39
40    /// Find professional skills for a building (Expert level OR has certifications)
41    async fn find_professional_by_building(&self, building_id: Uuid) -> Result<Vec<Skill>, String>;
42
43    /// Update an existing skill
44    async fn update(&self, skill: &Skill) -> Result<Skill, String>;
45
46    /// Delete a skill
47    async fn delete(&self, id: Uuid) -> Result<(), String>;
48
49    /// Count total skills for a building
50    async fn count_by_building(&self, building_id: Uuid) -> Result<i64, String>;
51
52    /// Count available skills for a building
53    async fn count_available_by_building(&self, building_id: Uuid) -> Result<i64, String>;
54
55    /// Count skills by category (for statistics)
56    async fn count_by_category(
57        &self,
58        building_id: Uuid,
59        category: SkillCategory,
60    ) -> Result<i64, String>;
61
62    /// Count skills by expertise level (for statistics)
63    async fn count_by_expertise(
64        &self,
65        building_id: Uuid,
66        level: ExpertiseLevel,
67    ) -> Result<i64, String>;
68}