@@ -8,14 +8,22 @@ use como_domain::{
|
||||
responses::CreatedItemDto,
|
||||
ItemDto,
|
||||
},
|
||||
users::User,
|
||||
Context,
|
||||
};
|
||||
|
||||
pub type DynItemService = Arc<dyn ItemService + Send + Sync>;
|
||||
|
||||
#[async_trait]
|
||||
pub trait ItemService {
|
||||
async fn add_item(&self, item: CreateItemDto, user: &User) -> anyhow::Result<CreatedItemDto>;
|
||||
async fn get_item(&self, query: GetItemQuery, user: &User) -> anyhow::Result<ItemDto>;
|
||||
async fn get_items(&self, query: GetItemsQuery, user: &User) -> anyhow::Result<Vec<ItemDto>>;
|
||||
async fn add_item(
|
||||
&self,
|
||||
context: &Context,
|
||||
item: CreateItemDto,
|
||||
) -> anyhow::Result<CreatedItemDto>;
|
||||
async fn get_item(&self, context: &Context, query: GetItemQuery) -> anyhow::Result<ItemDto>;
|
||||
async fn get_items(
|
||||
&self,
|
||||
context: &Context,
|
||||
query: GetItemsQuery,
|
||||
) -> anyhow::Result<Vec<ItemDto>>;
|
||||
}
|
||||
|
@@ -3,18 +3,22 @@ use std::sync::Arc;
|
||||
use async_trait::async_trait;
|
||||
use como_domain::{
|
||||
projects::{mutation::CreateProjectMutation, queries::GetProjectQuery, ProjectDto},
|
||||
users::User,
|
||||
Context,
|
||||
};
|
||||
|
||||
pub type DynProjectService = Arc<dyn ProjectService + Send + Sync>;
|
||||
|
||||
#[async_trait]
|
||||
pub trait ProjectService {
|
||||
async fn get_project(&self, query: GetProjectQuery) -> anyhow::Result<ProjectDto>;
|
||||
async fn get_projects(&self, user: &User) -> anyhow::Result<Vec<ProjectDto>>;
|
||||
async fn get_project(
|
||||
&self,
|
||||
context: &Context,
|
||||
query: GetProjectQuery,
|
||||
) -> anyhow::Result<ProjectDto>;
|
||||
async fn get_projects(&self, context: &Context) -> anyhow::Result<Vec<ProjectDto>>;
|
||||
async fn create_project(
|
||||
&self,
|
||||
context: &Context,
|
||||
name: CreateProjectMutation,
|
||||
user: &User,
|
||||
) -> anyhow::Result<ProjectDto>;
|
||||
}
|
||||
|
@@ -1,14 +1,21 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use como_domain::Context;
|
||||
|
||||
pub type DynUserService = Arc<dyn UserService + Send + Sync>;
|
||||
|
||||
#[async_trait]
|
||||
pub trait UserService {
|
||||
async fn add_user(&self, username: String, password: String) -> anyhow::Result<String>;
|
||||
async fn add_user(
|
||||
&self,
|
||||
context: &Context,
|
||||
username: String,
|
||||
password: String,
|
||||
) -> anyhow::Result<String>;
|
||||
async fn validate_user(
|
||||
&self,
|
||||
context: &Context,
|
||||
username: String,
|
||||
password: String,
|
||||
) -> anyhow::Result<Option<String>>;
|
||||
|
Reference in New Issue
Block a user