Benutzer, Gruppe, Rolle überarbeitet
This commit is contained in:
parent
fdc57ab13a
commit
f410791d4b
|
@ -1,35 +1,29 @@
|
|||
use async_graphql::{Context, FieldResult, Object};
|
||||
use async_graphql::{ComplexObject, Context, FieldResult, SimpleObject};
|
||||
use sqlx::PgPool;
|
||||
|
||||
use crate::{models::gruppe::Gruppe, scalar::Id};
|
||||
|
||||
use super::rolle::Rolle;
|
||||
|
||||
#[derive(SimpleObject)]
|
||||
#[graphql(complex)]
|
||||
pub struct Benutzer {
|
||||
/// Die UUID eines Benutzers
|
||||
pub id: Id,
|
||||
|
||||
/// Die Kennung des Benutzers
|
||||
pub kennung: String,
|
||||
|
||||
/// Der Vorname des Benutzers
|
||||
pub vorname: String,
|
||||
|
||||
/// Der Nachname des Benutzers
|
||||
pub nachname: String,
|
||||
}
|
||||
|
||||
#[Object]
|
||||
#[ComplexObject]
|
||||
impl Benutzer {
|
||||
pub async fn id(&self) -> Id {
|
||||
self.id
|
||||
}
|
||||
|
||||
pub async fn kennung(&self) -> &str {
|
||||
&self.kennung
|
||||
}
|
||||
|
||||
pub async fn vorname(&self) -> &str {
|
||||
&self.vorname
|
||||
}
|
||||
|
||||
pub async fn nachname(&self) -> &str {
|
||||
&self.nachname
|
||||
}
|
||||
|
||||
/// Die Rollen des Benutzers
|
||||
pub async fn rollen<'ctx>(&self, ctx: &Context<'ctx>) -> FieldResult<Vec<Rolle>> {
|
||||
let pool = ctx.data::<PgPool>()?;
|
||||
|
||||
|
@ -53,6 +47,7 @@ impl Benutzer {
|
|||
Ok(rows)
|
||||
}
|
||||
|
||||
/// Die Gruppen des Benutzers
|
||||
pub async fn gruppen<'ctx>(&self, ctx: &Context<'ctx>) -> FieldResult<Vec<Gruppe>> {
|
||||
let pool = ctx.data::<PgPool>()?;
|
||||
|
||||
|
|
|
@ -1,30 +1,22 @@
|
|||
use async_graphql::Object;
|
||||
use async_graphql::{ComplexObject, SimpleObject};
|
||||
|
||||
use crate::scalar::{Id, Time};
|
||||
|
||||
#[derive(SimpleObject)]
|
||||
#[graphql(complex)]
|
||||
pub struct Gruppe {
|
||||
/// Die UUIDl einer Gruppe
|
||||
pub id: Id,
|
||||
|
||||
/// Der Gruppenname
|
||||
pub gruppenname: String,
|
||||
|
||||
/// Wann die Gruppe erstellt wurde
|
||||
pub erstellt_am: Time,
|
||||
|
||||
/// Wann die Gruppe geaendert wurde
|
||||
pub geaendert_am: Time,
|
||||
}
|
||||
|
||||
#[Object]
|
||||
impl Gruppe {
|
||||
pub async fn id(&self) -> Id {
|
||||
self.id
|
||||
}
|
||||
|
||||
pub async fn gruppenname(&self) -> &str {
|
||||
&self.gruppenname
|
||||
}
|
||||
|
||||
pub async fn erstellt_am(&self) -> Time {
|
||||
self.erstellt_am
|
||||
}
|
||||
|
||||
pub async fn geaendert_am(&self) -> Time {
|
||||
self.geaendert_am
|
||||
}
|
||||
}
|
||||
#[ComplexObject]
|
||||
impl Gruppe {}
|
||||
|
|
|
@ -1,37 +1,30 @@
|
|||
use async_graphql::{Context, FieldResult, Object};
|
||||
use async_graphql::{ComplexObject, Context, FieldResult, SimpleObject};
|
||||
use sqlx::PgPool;
|
||||
|
||||
use crate::scalar::{Id, Time};
|
||||
|
||||
use super::gruppe::Gruppe;
|
||||
|
||||
#[derive(Debug)]
|
||||
/// Um die Administration zu erleichtern werden Gruppen in die Rollen hinzugefuegt
|
||||
#[derive(SimpleObject, Debug)]
|
||||
#[graphql(complex)]
|
||||
pub struct Rolle {
|
||||
/// Die uuid einer Rolle
|
||||
pub id: Id,
|
||||
|
||||
/// Der Rollenname
|
||||
pub rollenname: String,
|
||||
|
||||
/// Wann die Rolle erstellt wurde
|
||||
pub erstellt_am: Time,
|
||||
|
||||
/// Wann die Rolle geaendert wurde
|
||||
pub geaendert_am: Time,
|
||||
}
|
||||
|
||||
#[Object]
|
||||
#[ComplexObject]
|
||||
impl Rolle {
|
||||
pub async fn id(&self) -> Id {
|
||||
self.id
|
||||
}
|
||||
|
||||
pub async fn rollename(&self) -> &str {
|
||||
&self.rollenname
|
||||
}
|
||||
|
||||
pub async fn erstellt_am(&self) -> Time {
|
||||
self.erstellt_am
|
||||
}
|
||||
|
||||
pub async fn geaendert_am(&self) -> Time {
|
||||
self.geaendert_am
|
||||
}
|
||||
|
||||
/// Die Gruppen in einer Rolle
|
||||
pub async fn gruppen<'ctx>(&self, ctx: &Context<'ctx>) -> FieldResult<Vec<Gruppe>> {
|
||||
let pool = ctx.data::<PgPool>()?;
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use async_graphql::{Context, FieldResult, Object};
|
||||
use log::debug;
|
||||
use sqlx::postgres::PgPool;
|
||||
|
||||
use crate::models::rolle::Rolle;
|
||||
|
|
Loading…
Reference in New Issue