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"
[dependencies]
async-graphql = { version = "7.0.13", default-features = false, features = [
async-graphql = { version = "7.2.1", default-features = false, features = [
"chrono",
"uuid",
'dataloader',
'dynamic-schema',
'graphiql',
'playground',
] }
axum = { version = "0.7.9", features = ["macros"] }
sqlx = { version = "0.8.2", features = [
"runtime-tokio-native-tls",
axum = { version = "0.8.9", features = ["macros"] }
sqlx = { version = "0.9.0", features = [
"runtime-tokio",
"tls-native-tls",
"uuid",
"postgres",
"chrono",
"macros",
] }
anyhow = "1.0.94"
async-graphql-axum = "7.0.13"
chrono = { version = "0.4.39", features = ["serde"] }
anyhow = "1.0.102"
async-graphql-axum = "7.2.1"
chrono = { version = "0.4.44", features = ["serde"] }
dotenv = "0.15.0"
envy = "0.4.2"
env_logger = "0.11.5"
log = "0.4.22"
serde = "1.0.216"
tokio = { version = "1.42.0", features = ["macros", "rt-multi-thread"] }
env_logger = "0.11.10"
log = "0.4.30"
serde = "1.0.228"
tokio = { version = "1.52.3", features = ["macros", "rt-multi-thread"] }
# UUID
uuid = { version = "1.11.0", features = ["serde", "v4", "macro-diagnostics"] }
ulid = { version = "1.1.3", features = ["uuid"] }
uuid = { version = "1.23.1", features = ["serde", "v4", "macro-diagnostics"] }
ulid = { version = "1.2.1", features = ["uuid"] }
# Logging
tracing = "0.1.41"
tracing-subscriber = { version = "0.3.19", features = ["env-filter", "chrono"] }
tracing-appender = "0.2.3"
tracing = "0.1.44"
tracing-subscriber = { version = "0.3.23", features = ["env-filter", "chrono"] }
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,
erstellt_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',
'indirekt',
'beides'

View File

@@ -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?)

View File

@@ -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

View File

@@ -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

View File

@@ -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?;

View File

@@ -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)

View File

@@ -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)

View File

@@ -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?;

View File

@@ -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")

View File

@@ -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)