change queries

This commit is contained in:
2026-05-25 19:26:24 +02:00
parent e6a011f159
commit e0f78a12e1
12 changed files with 1375 additions and 1160 deletions

2459
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -4,39 +4,39 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
async-graphql = { version = "7.0.13", default-features = false, features = [ async-graphql = { version = "7.2.1", default-features = false, features = [
"chrono", "chrono",
"uuid", "uuid",
'dataloader', 'dataloader',
'dynamic-schema', 'dynamic-schema',
'graphiql', 'graphiql',
'playground',
] } ] }
axum = { version = "0.7.9", features = ["macros"] } axum = { version = "0.8.9", features = ["macros"] }
sqlx = { version = "0.8.2", features = [ sqlx = { version = "0.9.0", features = [
"runtime-tokio-native-tls", "runtime-tokio",
"tls-native-tls",
"uuid", "uuid",
"postgres", "postgres",
"chrono", "chrono",
"macros", "macros",
] } ] }
anyhow = "1.0.94" anyhow = "1.0.102"
async-graphql-axum = "7.0.13" async-graphql-axum = "7.2.1"
chrono = { version = "0.4.39", features = ["serde"] } chrono = { version = "0.4.44", features = ["serde"] }
dotenv = "0.15.0" dotenv = "0.15.0"
envy = "0.4.2" envy = "0.4.2"
env_logger = "0.11.5" env_logger = "0.11.10"
log = "0.4.22" log = "0.4.30"
serde = "1.0.216" serde = "1.0.228"
tokio = { version = "1.42.0", features = ["macros", "rt-multi-thread"] } tokio = { version = "1.52.3", features = ["macros", "rt-multi-thread"] }
# UUID # UUID
uuid = { version = "1.11.0", features = ["serde", "v4", "macro-diagnostics"] } uuid = { version = "1.23.1", features = ["serde", "v4", "macro-diagnostics"] }
ulid = { version = "1.1.3", features = ["uuid"] } ulid = { version = "1.2.1", features = ["uuid"] }
# Logging # Logging
tracing = "0.1.41" tracing = "0.1.44"
tracing-subscriber = { version = "0.3.19", features = ["env-filter", "chrono"] } tracing-subscriber = { version = "0.3.23", features = ["env-filter", "chrono"] }
tracing-appender = "0.2.3" tracing-appender = "0.2.5"
itertools = "0.13.0" itertools = "0.14.0"

View File

@@ -3,9 +3,9 @@ CREATE TABLE IF NOT EXISTS gruppen (
gruppenname VARCHAR NOT NULL, gruppenname VARCHAR NOT NULL,
erstellt_am TIMESTAMP WITH TIME ZONE NOT NULL, erstellt_am TIMESTAMP WITH TIME ZONE NOT NULL,
geaendert_am TIMESTAMP WITH TIME ZONE NOT NULL geaendert_am TIMESTAMP WITH TIME ZONE NOT NULL
) );
CREATE TYPE gruppen_herkunft AS ENUM ( CREATE TYPE GRUPPEN_HERKUNFT AS ENUM (
'direkt', 'direkt',
'indirekt', 'indirekt',
'beides' 'beides'

View File

@@ -26,21 +26,21 @@ pub struct Benutzer {
#[ComplexObject] #[ComplexObject]
impl Benutzer { impl Benutzer {
/// Die Rollen des Benutzers /// 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>()?; let loader = ctx.data::<LoaderContext>()?;
Ok(loader.rollen.load_one(self.id).await?) Ok(loader.rollen.load_one(self.id).await?)
} }
/// Die Gruppen des Benutzers /// 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>()?; let loader = ctx.data::<LoaderContext>()?;
Ok(loader.gruppen.load_one(self.id).await?) Ok(loader.gruppen.load_one(self.id).await?)
} }
/// Die Gruppen eines Benutzer kumulativ mit den Gruppen aus den Rollen /// Die Gruppen eines Benutzer kumulativ mit den Gruppen aus den Rollen
pub async fn gruppen_kumulativ<'ctx>( pub async fn gruppen_kumulativ(
&self, &self,
ctx: &Context<'ctx>, ctx: &Context<'_>,
) -> FieldResult<Option<Vec<GruppeAnsicht>>> { ) -> FieldResult<Option<Vec<GruppeAnsicht>>> {
let loader = ctx.data::<LoaderContext>()?; let loader = ctx.data::<LoaderContext>()?;
Ok(loader.benutzer_gruppen_kumulativ.load_one(self.id).await?) Ok(loader.benutzer_gruppen_kumulativ.load_one(self.id).await?)

View File

@@ -6,7 +6,7 @@ use crate::domain::gruppe::model::Gruppe;
use super::Repository; use super::Repository;
impl 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!( // let rows = sqlx::query!(
// r#" // r#"
// SELECT // SELECT

View File

@@ -5,7 +5,7 @@ use crate::scalar::{Id, Time};
#[derive(sqlx::FromRow, SimpleObject, Clone, Debug)] #[derive(sqlx::FromRow, SimpleObject, Clone, Debug)]
#[graphql(complex)] #[graphql(complex)]
pub struct Gruppe { pub struct Gruppe {
/// Die UUIDl einer Gruppe /// Die UUID einer Gruppe
pub id: Id, pub id: Id,
/// Der Gruppenname /// Der Gruppenname

View File

@@ -14,7 +14,7 @@ impl BenutzerQuery {
// Ok(row) // 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 pool = ctx.data::<PgPool>()?;
let benutzer = Service::new(pool.clone()).alle_benutzer().await?; let benutzer = Service::new(pool.clone()).alle_benutzer().await?;

View File

@@ -8,14 +8,14 @@ pub struct GruppeQuery {}
#[Object(extends)] #[Object(extends)]
impl GruppeQuery { 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!(); todo!();
// let pool = ctx.data::<PgPool>()?; // let pool = ctx.data::<PgPool>()?;
// //
// Ok(row) // 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 pool = ctx.data::<PgPool>()?;
let rows = Service::new(pool.clone()).gruppe_alle().await?; let rows = Service::new(pool.clone()).gruppe_alle().await?;
Ok(rows) Ok(rows)

View File

@@ -8,17 +8,13 @@ pub struct HerstellerQuery {}
#[Object(extends)] #[Object(extends)]
impl HerstellerQuery { impl HerstellerQuery {
async fn hersteller<'a>( async fn hersteller(&self, ctx: &Context<'_>, id: uuid::Uuid) -> FieldResult<Hersteller> {
&self,
ctx: &'a Context<'_>,
id: uuid::Uuid,
) -> FieldResult<Hersteller> {
let pool = ctx.data::<PgPool>()?; let pool = ctx.data::<PgPool>()?;
let row = Hersteller::read_one(pool, &id).await?; let row = Hersteller::read_one(pool, &id).await?;
Ok(row) 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 pool = ctx.data::<PgPool>()?;
let rows = Hersteller::read_all(pool).await?; let rows = Hersteller::read_all(pool).await?;
Ok(rows) Ok(rows)

View File

@@ -8,13 +8,13 @@ pub struct ModellQuery {}
#[Object(extends)] #[Object(extends)]
impl ModellQuery { 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 pool = ctx.data::<PgPool>()?;
let row = Modell::read_one(pool, &id).await?; let row = Modell::read_one(pool, &id).await?;
Ok(row) 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 pool = ctx.data::<PgPool>()?;
let output = Modell::read_all(pool).await?; let output = Modell::read_all(pool).await?;

View File

@@ -14,7 +14,7 @@ impl RolleQuery {
// Ok(row) // 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 pool = ctx.data::<PgPool>()?;
let rollen = sqlx::query_as!(Rolle, "SELECT * FROM rollen") let rollen = sqlx::query_as!(Rolle, "SELECT * FROM rollen")

View File

@@ -8,13 +8,13 @@ pub struct TypQuery {}
#[Object(extends)] #[Object(extends)]
impl TypQuery { 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 pool = ctx.data::<PgPool>()?;
let rows = Typ::read_all(pool).await?; let rows = Typ::read_all(pool).await?;
Ok(rows) 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 pool = ctx.data::<PgPool>()?;
let row = Typ::read_one(pool, &id).await?; let row = Typ::read_one(pool, &id).await?;
Ok(row) Ok(row)