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>;
|
||||
}
|
Reference in New Issue
Block a user