feat: working projects and items
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
@@ -2,6 +2,7 @@ use async_graphql::{Context, Object};
|
||||
use como_domain::{
|
||||
item::{queries::GetItemQuery, ItemDto, ItemState},
|
||||
projects::queries::GetProjectQuery,
|
||||
users::User,
|
||||
};
|
||||
use como_infrastructure::register::ServiceRegister;
|
||||
use uuid::Uuid;
|
||||
@@ -15,10 +16,12 @@ pub struct CreatedItem {
|
||||
#[Object]
|
||||
impl CreatedItem {
|
||||
pub async fn item(&self, ctx: &Context<'_>) -> anyhow::Result<Item> {
|
||||
let user = ctx.data_unchecked::<User>();
|
||||
|
||||
let item = ctx
|
||||
.data_unchecked::<ServiceRegister>()
|
||||
.item_service
|
||||
.get_item(GetItemQuery { item_id: self.id })
|
||||
.get_item(GetItemQuery { item_id: self.id }, user)
|
||||
.await?;
|
||||
|
||||
Ok(item.into())
|
||||
@@ -30,6 +33,7 @@ pub struct Item {
|
||||
pub title: String,
|
||||
pub description: Option<String>,
|
||||
pub state: ItemState,
|
||||
pub project_id: Uuid,
|
||||
}
|
||||
|
||||
#[Object]
|
||||
@@ -55,13 +59,16 @@ impl Item {
|
||||
.data_unchecked::<ServiceRegister>()
|
||||
.project_service
|
||||
.get_project(GetProjectQuery {
|
||||
item_id: Some(self.id),
|
||||
project_id: None,
|
||||
project_id: self.project_id,
|
||||
})
|
||||
.await?;
|
||||
|
||||
Ok(project.into())
|
||||
}
|
||||
|
||||
pub async fn project_id(&self, _ctx: &Context<'_>) -> anyhow::Result<Uuid> {
|
||||
return Ok(self.project_id);
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ItemDto> for Item {
|
||||
@@ -71,6 +78,7 @@ impl From<ItemDto> for Item {
|
||||
title: dto.title,
|
||||
description: dto.description,
|
||||
state: dto.state,
|
||||
project_id: dto.project_id,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user