change queries
This commit is contained in:
@@ -26,21 +26,21 @@ pub struct Benutzer {
|
||||
#[ComplexObject]
|
||||
impl Benutzer {
|
||||
/// Die Rollen des Benutzers
|
||||
pub async fn rollen<'ctx>(&self, ctx: &Context<'ctx>) -> FieldResult<Option<Vec<Rolle>>> {
|
||||
pub async fn rollen(&self, ctx: &Context<'_>) -> FieldResult<Option<Vec<Rolle>>> {
|
||||
let loader = ctx.data::<LoaderContext>()?;
|
||||
Ok(loader.rollen.load_one(self.id).await?)
|
||||
}
|
||||
|
||||
/// Die Gruppen des Benutzers
|
||||
pub async fn gruppen<'ctx>(&self, ctx: &Context<'ctx>) -> FieldResult<Option<Vec<Gruppe>>> {
|
||||
pub async fn gruppen(&self, ctx: &Context<'_>) -> FieldResult<Option<Vec<Gruppe>>> {
|
||||
let loader = ctx.data::<LoaderContext>()?;
|
||||
Ok(loader.gruppen.load_one(self.id).await?)
|
||||
}
|
||||
|
||||
/// Die Gruppen eines Benutzer kumulativ mit den Gruppen aus den Rollen
|
||||
pub async fn gruppen_kumulativ<'ctx>(
|
||||
pub async fn gruppen_kumulativ(
|
||||
&self,
|
||||
ctx: &Context<'ctx>,
|
||||
ctx: &Context<'_>,
|
||||
) -> FieldResult<Option<Vec<GruppeAnsicht>>> {
|
||||
let loader = ctx.data::<LoaderContext>()?;
|
||||
Ok(loader.benutzer_gruppen_kumulativ.load_one(self.id).await?)
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::domain::gruppe::model::Gruppe;
|
||||
use super::Repository;
|
||||
|
||||
impl Repository {
|
||||
pub async fn find_gruppen<'a>(&self, ctx: &'a Context<'_>) -> Result<Vec<Gruppe>, Error> {
|
||||
pub async fn find_gruppen(&self, _ctx: &Context<'_>) -> Result<Vec<Gruppe>, Error> {
|
||||
// let rows = sqlx::query!(
|
||||
// r#"
|
||||
// SELECT
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::scalar::{Id, Time};
|
||||
#[derive(sqlx::FromRow, SimpleObject, Clone, Debug)]
|
||||
#[graphql(complex)]
|
||||
pub struct Gruppe {
|
||||
/// Die UUIDl einer Gruppe
|
||||
/// Die UUID einer Gruppe
|
||||
pub id: Id,
|
||||
|
||||
/// Der Gruppenname
|
||||
|
||||
@@ -14,7 +14,7 @@ impl BenutzerQuery {
|
||||
// Ok(row)
|
||||
// }
|
||||
|
||||
async fn benutzer_alle<'a>(&self, ctx: &'a Context<'_>) -> FieldResult<Vec<Benutzer>> {
|
||||
async fn benutzer_alle(&self, ctx: &Context<'_>) -> FieldResult<Vec<Benutzer>> {
|
||||
let pool = ctx.data::<PgPool>()?;
|
||||
|
||||
let benutzer = Service::new(pool.clone()).alle_benutzer().await?;
|
||||
|
||||
@@ -8,14 +8,14 @@ pub struct GruppeQuery {}
|
||||
|
||||
#[Object(extends)]
|
||||
impl GruppeQuery {
|
||||
async fn gruppe<'a>(&self, ctx: &'a Context<'_>, id: uuid::Uuid) -> FieldResult<Gruppe> {
|
||||
async fn gruppe(&self, ctx: &Context<'_>, id: uuid::Uuid) -> FieldResult<Gruppe> {
|
||||
todo!();
|
||||
// let pool = ctx.data::<PgPool>()?;
|
||||
//
|
||||
// Ok(row)
|
||||
}
|
||||
|
||||
async fn gruppen<'a>(&self, ctx: &'a Context<'_>) -> FieldResult<Vec<Gruppe>> {
|
||||
async fn gruppen(&self, ctx: &Context<'_>) -> FieldResult<Vec<Gruppe>> {
|
||||
let pool = ctx.data::<PgPool>()?;
|
||||
let rows = Service::new(pool.clone()).gruppe_alle().await?;
|
||||
Ok(rows)
|
||||
|
||||
@@ -8,17 +8,13 @@ pub struct HerstellerQuery {}
|
||||
|
||||
#[Object(extends)]
|
||||
impl HerstellerQuery {
|
||||
async fn hersteller<'a>(
|
||||
&self,
|
||||
ctx: &'a Context<'_>,
|
||||
id: uuid::Uuid,
|
||||
) -> FieldResult<Hersteller> {
|
||||
async fn hersteller(&self, ctx: &Context<'_>, id: uuid::Uuid) -> FieldResult<Hersteller> {
|
||||
let pool = ctx.data::<PgPool>()?;
|
||||
let row = Hersteller::read_one(pool, &id).await?;
|
||||
Ok(row)
|
||||
}
|
||||
|
||||
async fn alle_hersteller<'a>(&self, ctx: &'a Context<'_>) -> FieldResult<Vec<Hersteller>> {
|
||||
async fn alle_hersteller(&self, ctx: &Context<'_>) -> FieldResult<Vec<Hersteller>> {
|
||||
let pool = ctx.data::<PgPool>()?;
|
||||
let rows = Hersteller::read_all(pool).await?;
|
||||
Ok(rows)
|
||||
|
||||
@@ -8,13 +8,13 @@ pub struct ModellQuery {}
|
||||
|
||||
#[Object(extends)]
|
||||
impl ModellQuery {
|
||||
async fn modell<'a>(&self, ctx: &'a Context<'_>, id: Id) -> FieldResult<Modell> {
|
||||
async fn modell(&self, ctx: &Context<'_>, id: Id) -> FieldResult<Modell> {
|
||||
let pool = ctx.data::<PgPool>()?;
|
||||
let row = Modell::read_one(pool, &id).await?;
|
||||
Ok(row)
|
||||
}
|
||||
|
||||
async fn modelle<'a>(&self, ctx: &'a Context<'_>) -> FieldResult<Vec<Modell>> {
|
||||
async fn modelle(&self, ctx: &Context<'_>) -> FieldResult<Vec<Modell>> {
|
||||
let pool = ctx.data::<PgPool>()?;
|
||||
let output = Modell::read_all(pool).await?;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ impl RolleQuery {
|
||||
// Ok(row)
|
||||
// }
|
||||
|
||||
async fn rollen<'a>(&self, ctx: &'a Context<'_>) -> FieldResult<Vec<Rolle>> {
|
||||
async fn rollen(&self, ctx: &Context<'_>) -> FieldResult<Vec<Rolle>> {
|
||||
let pool = ctx.data::<PgPool>()?;
|
||||
|
||||
let rollen = sqlx::query_as!(Rolle, "SELECT * FROM rollen")
|
||||
|
||||
@@ -8,13 +8,13 @@ pub struct TypQuery {}
|
||||
|
||||
#[Object(extends)]
|
||||
impl TypQuery {
|
||||
async fn typen<'a>(&self, ctx: &'a Context<'_>) -> FieldResult<Vec<Typ>> {
|
||||
async fn typen(&self, ctx: &Context<'_>) -> FieldResult<Vec<Typ>> {
|
||||
let pool = ctx.data::<PgPool>()?;
|
||||
let rows = Typ::read_all(pool).await?;
|
||||
Ok(rows)
|
||||
}
|
||||
|
||||
async fn typ<'a>(&self, ctx: &'a Context<'_>, id: Id) -> FieldResult<Typ> {
|
||||
async fn typ(&self, ctx: &Context<'_>, id: Id) -> FieldResult<Typ> {
|
||||
let pool = ctx.data::<PgPool>()?;
|
||||
let row = Typ::read_one(pool, &id).await?;
|
||||
Ok(row)
|
||||
|
||||
Reference in New Issue
Block a user