12
crates/como_core/Cargo.toml
Normal file
12
crates/como_core/Cargo.toml
Normal file
@@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "como_core"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
como_domain.workspace = true
|
||||
|
||||
async-trait.workspace = true
|
||||
anyhow.workspace = true
|
5
crates/como_core/report.json
Normal file
5
crates/como_core/report.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"version": 0,
|
||||
"root_name": "Workspace",
|
||||
"workspace_crates": {}
|
||||
}
|
31
crates/como_core/src/items/mod.rs
Normal file
31
crates/como_core/src/items/mod.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use como_domain::{
|
||||
item::{
|
||||
queries::{GetItemQuery, GetItemsQuery},
|
||||
requests::{CreateItemDto, UpdateItemDto},
|
||||
responses::CreatedItemDto,
|
||||
ItemDto,
|
||||
},
|
||||
Context,
|
||||
};
|
||||
|
||||
pub type DynItemService = Arc<dyn ItemService + Send + Sync>;
|
||||
|
||||
#[async_trait]
|
||||
pub trait ItemService {
|
||||
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>>;
|
||||
|
||||
async fn update_item(&self, context: &Context, item: UpdateItemDto) -> anyhow::Result<ItemDto>;
|
||||
}
|
3
crates/como_core/src/lib.rs
Normal file
3
crates/como_core/src/lib.rs
Normal file
@@ -0,0 +1,3 @@
|
||||
pub mod items;
|
||||
pub mod projects;
|
||||
pub mod users;
|
24
crates/como_core/src/projects/mod.rs
Normal file
24
crates/como_core/src/projects/mod.rs
Normal file
@@ -0,0 +1,24 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use como_domain::{
|
||||
projects::{mutation::CreateProjectMutation, queries::GetProjectQuery, ProjectDto},
|
||||
Context,
|
||||
};
|
||||
|
||||
pub type DynProjectService = Arc<dyn ProjectService + Send + Sync>;
|
||||
|
||||
#[async_trait]
|
||||
pub trait ProjectService {
|
||||
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,
|
||||
) -> anyhow::Result<ProjectDto>;
|
||||
}
|
22
crates/como_core/src/users/mod.rs
Normal file
22
crates/como_core/src/users/mod.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
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,
|
||||
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