feat: with items

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2023-06-04 11:02:51 +02:00
parent 12c7c8f6ee
commit 534b2e4a23
25 changed files with 517 additions and 111 deletions

View File

@@ -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>>;
}

View File

@@ -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>;
}

View File

@@ -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>>;