From b3b7b75ea8f90af8e6b8847935384f61b9da9b39 Mon Sep 17 00:00:00 2001 From: Peter Date: Wed, 3 Jun 2026 22:08:44 +0200 Subject: [PATCH] typ refactor --- migrations/20240530193519_typen.up.sql | 3 ++- migrations/20240530193528_hersteller.up.sql | 3 ++- migrations/20240530193533_modelle.up.sql | 4 ++-- .../20241202221730_liegenschaften.up.sql | 2 +- src/domain/typ.rs | 1 + src/domain/typ/entity.rs | 6 +++++- src/domain/typ/entity/typ.rs | 21 ++++++++++++++----- src/domain/typ/model/typ.rs | 10 ++++----- src/domain/typ/model/typ_loeschen_input.rs | 6 +++--- src/domain/typ/model/typ_update_input.rs | 7 ++++--- src/domain/typ/mutation.rs | 3 +++ src/{mutations => domain/typ/mutation}/typ.rs | 5 +++-- .../typ/repository/typ_erstelle_viele.rs | 19 ++++++++++------- src/domain/typ/repository/typ_erstellen.rs | 9 ++++---- src/domain/typ/repository/typ_loeschen.rs | 4 ++-- src/domain/typ/repository/typ_update.rs | 4 ++-- src/domain/typ/service/typ_erstellen.rs | 11 +++++----- src/domain/typ/service/typ_erstellen_viele.rs | 13 ++++++------ src/domain/typ/service/typ_loeschen.rs | 10 ++------- src/domain/typ/service/typ_update.rs | 5 ++--- src/mutations/mod.rs | 5 +++-- src/scalar.rs | 5 +++++ 22 files changed, 92 insertions(+), 64 deletions(-) create mode 100644 src/domain/typ/mutation.rs rename src/{mutations => domain/typ/mutation}/typ.rs (91%) diff --git a/migrations/20240530193519_typen.up.sql b/migrations/20240530193519_typen.up.sql index aa0a00a..68b4081 100644 --- a/migrations/20240530193519_typen.up.sql +++ b/migrations/20240530193519_typen.up.sql @@ -1,5 +1,6 @@ CREATE TABLE IF NOT EXISTS typen ( - id UUID PRIMARY KEY, + typ_id UUID PRIMARY KEY, + id CHAR(26) UNIQUE NOT NULL, typname VARCHAR NOT NULL, erstellt_am TIMESTAMP WITH TIME ZONE NOT NULL, geaendert_am TIMESTAMP WITH TIME ZONE NOT NULL diff --git a/migrations/20240530193528_hersteller.up.sql b/migrations/20240530193528_hersteller.up.sql index 5c85d05..3f31597 100644 --- a/migrations/20240530193528_hersteller.up.sql +++ b/migrations/20240530193528_hersteller.up.sql @@ -1,5 +1,6 @@ CREATE TABLE IF NOT EXISTS hersteller ( - id UUID PRIMARY KEY, + hersteller_id UUID PRIMARY KEY, + id CHAR(26) UNIQUE NOT NULL, herstellername VARCHAR NOT NULL, erstellt_am TIMESTAMP WITH TIME ZONE NOT NULL, geaendert_am TIMESTAMP WITH TIME ZONE NOT NULL diff --git a/migrations/20240530193533_modelle.up.sql b/migrations/20240530193533_modelle.up.sql index 1fa9ca9..d7055db 100644 --- a/migrations/20240530193533_modelle.up.sql +++ b/migrations/20240530193533_modelle.up.sql @@ -5,12 +5,12 @@ CREATE TABLE IF NOT EXISTS modelle ( hersteller_id UUID, CONSTRAINT fk_typ FOREIGN KEY (typ_id) - REFERENCES typen (id) + REFERENCES typen (typ_id) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT fk_hersteller FOREIGN KEY (hersteller_id) - REFERENCES hersteller (id) + REFERENCES hersteller (hersteller_id) ON DELETE NO ACTION ON UPDATE NO ACTION ) diff --git a/migrations/20241202221730_liegenschaften.up.sql b/migrations/20241202221730_liegenschaften.up.sql index c5f165d..1ea93f9 100644 --- a/migrations/20241202221730_liegenschaften.up.sql +++ b/migrations/20241202221730_liegenschaften.up.sql @@ -1,6 +1,6 @@ CREATE TABLE IF NOT EXISTS liegenschaften ( id_liegenschaft UUID PRIMARY KEY, - id VARCHAR UNIQUE, + id CHAR(26) UNIQUE, liegenschaftname VARCHAR NOT NULL, erstellt_am TIMESTAMP WITH TIME ZONE NOT NULL, geaendert_am TIMESTAMP WITH TIME ZONE NOT NULL diff --git a/src/domain/typ.rs b/src/domain/typ.rs index 758c8f6..9daf971 100644 --- a/src/domain/typ.rs +++ b/src/domain/typ.rs @@ -1,6 +1,7 @@ pub mod dataloader; pub mod entity; pub mod model; +pub mod mutation; pub mod queries; pub mod repository; pub mod service; diff --git a/src/domain/typ/entity.rs b/src/domain/typ/entity.rs index b77726a..c0c5e1d 100644 --- a/src/domain/typ/entity.rs +++ b/src/domain/typ/entity.rs @@ -1,2 +1,6 @@ pub mod typ; -pub use typ::Typ; + +// pub use typ::Typ; +pub use typ::TypErstellen; +pub use typ::TypLoeschen; +pub use typ::TypUpdate; diff --git a/src/domain/typ/entity/typ.rs b/src/domain/typ/entity/typ.rs index 89944e5..08f59db 100644 --- a/src/domain/typ/entity/typ.rs +++ b/src/domain/typ/entity/typ.rs @@ -1,8 +1,19 @@ -use crate::scalar::{Id, Time}; +use crate::scalar::{Id, Time, Ulid}; -pub struct Typ { - pub id: Id, +pub struct TypErstellen { + pub typ_id: Id, + pub id: Ulid, pub typname: String, - pub erstellt_am: Option