diff --git a/src/domain/rolle.rs b/src/domain/rolle.rs index e8cc49b..3adb766 100644 --- a/src/domain/rolle.rs +++ b/src/domain/rolle.rs @@ -1,5 +1,5 @@ pub mod entity; pub mod model; +pub mod mutation; pub mod repository; pub mod service; - diff --git a/src/domain/rolle/model.rs b/src/domain/rolle/model.rs index e9e6de2..0080c30 100644 --- a/src/domain/rolle/model.rs +++ b/src/domain/rolle/model.rs @@ -1,5 +1,6 @@ -mod create_rolle_input; mod rolle; -mod update_rolle_input; +mod rolle_create_input; +mod rolle_update_input; -pub use create_rolle_input::CreateRolleInput; +pub use rolle::Rolle; +pub use rolle_create_input::RolleCreateInput; diff --git a/src/domain/rolle/model/rolle.rs b/src/domain/rolle/model/rolle.rs index c954d57..8407cd5 100644 --- a/src/domain/rolle/model/rolle.rs +++ b/src/domain/rolle/model/rolle.rs @@ -10,6 +10,9 @@ pub struct Rolle { /// Wann die Rolle erstellt wurde pub created_at: Time, + /// Wann die Rolle geƤndert wurde + pub updated_at: Time, + /// Der Name einer Rolle pub name: String, } diff --git a/src/domain/rolle/model/create_rolle_input.rs b/src/domain/rolle/model/rolle_create_input.rs similarity index 78% rename from src/domain/rolle/model/create_rolle_input.rs rename to src/domain/rolle/model/rolle_create_input.rs index 6b7eeb9..544cee9 100644 --- a/src/domain/rolle/model/create_rolle_input.rs +++ b/src/domain/rolle/model/rolle_create_input.rs @@ -1,7 +1,7 @@ use async_graphql::InputObject; #[derive(InputObject)] -pub struct CreateRolleInput { +pub struct RolleCreateInput { /// Der Name einer Rolle pub name: String, } diff --git a/src/domain/rolle/model/update_rolle_input.rs b/src/domain/rolle/model/rolle_update_input.rs similarity index 85% rename from src/domain/rolle/model/update_rolle_input.rs rename to src/domain/rolle/model/rolle_update_input.rs index 8dbc231..180d973 100644 --- a/src/domain/rolle/model/update_rolle_input.rs +++ b/src/domain/rolle/model/rolle_update_input.rs @@ -3,7 +3,7 @@ use async_graphql::InputObject; use crate::scalar::Id; #[derive(InputObject)] -pub struct UpdateRolleInput { +pub struct RolleUpdateInput { /// Die ID einer Rolle pub id: Id, diff --git a/src/domain/rolle/mutation.rs b/src/domain/rolle/mutation.rs new file mode 100644 index 0000000..b497a47 --- /dev/null +++ b/src/domain/rolle/mutation.rs @@ -0,0 +1,35 @@ +use super::model::*; +use async_graphql::{Context, FieldResult}; +use sqlx::postgres::PgPool; + +#[derive(Default)] +pub struct RolleMutation; + +#[async_graphql::Object] +impl RolleMutation { + async fn create_rollen( + &self, + ctx: &Context<'_>, + input: RolleCreateInput, + ) -> FieldResult { + let pool = ctx.data::()?; + todo!(); + // let row = Rolle::create(pool, &input).await?; + // Ok(row) + } + + // async fn update_rollen( + // &self, + // ctx: &Context<'_>, + // input: RolleUpdateInput, + // ) -> FieldResult { + // let pool = ctx.data::()?; + // let row = Rolle::update(pool, &input).await?; + // Ok(row) + // } + // + // async fn delete_rollen(&self, ctx: &Context<'_>, id: i32) -> FieldResult { + // let pool = ctx.data::()?; + // Ok(Rolle::delete(pool, &id).await?) + // } +} diff --git a/src/domain/rolle/repository.rs b/src/domain/rolle/repository.rs index 846849e..e03bb34 100644 --- a/src/domain/rolle/repository.rs +++ b/src/domain/rolle/repository.rs @@ -1,7 +1,7 @@ mod create_rolle; mod delete_rolle; mod find_all_rolle; -mod find_rolle; +mod find_rolle_by_id; mod update_rolle; #[derive(Debug, Clone)] diff --git a/src/domain/rolle/repository/create_rolle.rs b/src/domain/rolle/repository/create_rolle.rs index 1e90476..472d935 100644 --- a/src/domain/rolle/repository/create_rolle.rs +++ b/src/domain/rolle/repository/create_rolle.rs @@ -1,6 +1,7 @@ use anyhow::Error; use super::Repository; +// use crate::domain::rolle::model; use crate::{database::Queryer, domain::rolle::entity}; impl Repository { diff --git a/src/domain/rolle/repository/find_rolle.rs b/src/domain/rolle/repository/find_rolle_by_id.rs similarity index 100% rename from src/domain/rolle/repository/find_rolle.rs rename to src/domain/rolle/repository/find_rolle_by_id.rs diff --git a/src/domain/rolle/service/create_user.rs b/src/domain/rolle/service/create_user.rs index 7f17cad..0bf8586 100644 --- a/src/domain/rolle/service/create_user.rs +++ b/src/domain/rolle/service/create_user.rs @@ -4,10 +4,10 @@ use ulid::Ulid; use super::Service; use crate::domain::rolle::entity; -use crate::domain::rolle::model::CreateRolleInput; +use crate::domain::rolle::model::RolleCreateInput; impl Service { - pub async fn create_rolle(&self, input: CreateRolleInput) -> Result { + pub async fn create_rolle(&self, input: RolleCreateInput) -> Result { // let username_exists = self.check_username_exists(&self.db, &input.name).await?; // if username_exists { // return Err(Error::UsernameAlreadyExists.into()); diff --git a/src/models/hersteller.rs b/src/models/hersteller.rs index a3d3254..b23ae69 100644 --- a/src/models/hersteller.rs +++ b/src/models/hersteller.rs @@ -14,12 +14,16 @@ pub struct Hersteller { #[derive(InputObject, Debug)] pub struct HerstellerCreateInput { + /// Der Name eines Herstellers pub name: String, } #[derive(InputObject, Debug)] pub struct HerstellerUpdateInput { + /// Die Datenbank-ID pub id: i32, + + /// Der Name eines Herstellers pub name: Option, }