2022-10-03 23:00:31 +02:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
|
|
use async_trait::async_trait;
|
2023-05-28 17:17:22 +02:00
|
|
|
use como_domain::{
|
|
|
|
item::{
|
|
|
|
queries::{GetItemQuery, GetItemsQuery},
|
2023-06-04 14:42:38 +02:00
|
|
|
requests::{CreateItemDto, UpdateItemDto},
|
2023-05-28 17:17:22 +02:00
|
|
|
responses::CreatedItemDto,
|
|
|
|
ItemDto,
|
|
|
|
},
|
2023-06-04 11:02:51 +02:00
|
|
|
Context,
|
2022-10-04 22:39:57 +02:00
|
|
|
};
|
2022-10-03 23:00:31 +02:00
|
|
|
|
|
|
|
pub type DynItemService = Arc<dyn ItemService + Send + Sync>;
|
|
|
|
|
|
|
|
#[async_trait]
|
2022-10-04 11:06:48 +02:00
|
|
|
pub trait ItemService {
|
2023-06-04 11:02:51 +02:00
|
|
|
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>>;
|
2023-06-04 14:42:38 +02:00
|
|
|
|
|
|
|
async fn update_item(&self, context: &Context, item: UpdateItemDto) -> anyhow::Result<ItemDto>;
|
2022-10-04 11:06:48 +02:00
|
|
|
}
|