| 1 |
use super::{MilestoneId, NaiveDate, NewProject, Project, ProjectId, Result, UserId, async_trait}; |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#[async_trait] |
| 7 |
pub trait ProjectRepository: Send + Sync { |
| 8 |
|
| 9 |
async fn list_all(&self, user_id: UserId) -> Result<Vec<Project>>; |
| 10 |
|
| 11 |
|
| 12 |
async fn get_by_id(&self, id: ProjectId, user_id: UserId) -> Result<Option<Project>>; |
| 13 |
|
| 14 |
|
| 15 |
async fn create(&self, user_id: UserId, project: NewProject) -> Result<Project>; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
async fn restore(&self, user_id: UserId, project: &Project) -> Result<()>; |
| 21 |
|
| 22 |
|
| 23 |
async fn update( |
| 24 |
&self, |
| 25 |
id: ProjectId, |
| 26 |
user_id: UserId, |
| 27 |
project: crate::models::UpdateProject, |
| 28 |
) -> Result<Option<Project>>; |
| 29 |
|
| 30 |
|
| 31 |
async fn delete(&self, id: ProjectId, user_id: UserId) -> Result<bool>; |
| 32 |
|
| 33 |
|
| 34 |
async fn find_by_name(&self, user_id: UserId, name: &str) -> Result<Option<Project>>; |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
#[async_trait] |
| 39 |
pub trait MilestoneRepository: Send + Sync { |
| 40 |
|
| 41 |
async fn list_by_project( |
| 42 |
&self, |
| 43 |
project_id: ProjectId, |
| 44 |
user_id: UserId, |
| 45 |
) -> Result<Vec<crate::models::Milestone>>; |
| 46 |
|
| 47 |
|
| 48 |
async fn list_all(&self, user_id: UserId) -> Result<Vec<crate::models::Milestone>>; |
| 49 |
|
| 50 |
|
| 51 |
async fn get_by_id( |
| 52 |
&self, |
| 53 |
id: MilestoneId, |
| 54 |
user_id: UserId, |
| 55 |
) -> Result<Option<crate::models::Milestone>>; |
| 56 |
|
| 57 |
|
| 58 |
async fn create( |
| 59 |
&self, |
| 60 |
user_id: UserId, |
| 61 |
milestone: crate::models::NewMilestone, |
| 62 |
) -> Result<crate::models::Milestone>; |
| 63 |
|
| 64 |
|
| 65 |
async fn update( |
| 66 |
&self, |
| 67 |
id: MilestoneId, |
| 68 |
user_id: UserId, |
| 69 |
name: &str, |
| 70 |
description: &str, |
| 71 |
target_date: Option<NaiveDate>, |
| 72 |
status: &crate::models::MilestoneStatus, |
| 73 |
) -> Result<Option<crate::models::Milestone>>; |
| 74 |
|
| 75 |
|
| 76 |
async fn delete(&self, id: MilestoneId, user_id: UserId) -> Result<bool>; |
| 77 |
|
| 78 |
|
| 79 |
async fn reorder( |
| 80 |
&self, |
| 81 |
project_id: ProjectId, |
| 82 |
user_id: UserId, |
| 83 |
milestone_ids: &[MilestoneId], |
| 84 |
) -> Result<()>; |
| 85 |
} |
| 86 |
|