From 1725d2538ceb95c066692b0c08e6d8c4f81e9eb6 Mon Sep 17 00:00:00 2001 From: schn33fuchs Date: Wed, 22 Apr 2026 18:45:02 +0200 Subject: [PATCH] Added status Struct --- backend/src/models.rs | 22 +++++++++++++++++++++- migrations/20260422094706_ticket_table.sql | 3 ++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/backend/src/models.rs b/backend/src/models.rs index 5a4e96f..0f446d0 100644 --- a/backend/src/models.rs +++ b/backend/src/models.rs @@ -25,13 +25,33 @@ impl Display for Category { } } -#[derive(Deserialize, Serialize, PartialEq, Debug)] +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +pub enum Status { + ToDo, + InProgress, + Done, + Archived, +} + +impl Display for Status { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::ToDo => write!(f, "ToDo"), + Self::InProgress => write!(f, "InProgress"), + Self::Done => write!(f, "Done"), + Self::Archived => write!(f, "Archived"), + } + } +} + +#[derive(Deserialize, Serialize, PartialEq, Debug, sqlx::FromRow)] pub struct Ticket { pub id: i32, pub category: Category, pub betreff: String, pub description: String, pub room: i16, + pub status: Status, pub date: chrono::NaiveDateTime, pub user_id: i16, } diff --git a/migrations/20260422094706_ticket_table.sql b/migrations/20260422094706_ticket_table.sql index 53ef6a9..ec765b1 100644 --- a/migrations/20260422094706_ticket_table.sql +++ b/migrations/20260422094706_ticket_table.sql @@ -1,11 +1,12 @@ CREATE TYPE category AS ENUM('Whiteboard Beamer', 'Internet', 'iPad Koffer', 'Apple TV', 'Docu Cam', 'Sonstiges') - +CREAYE TYPE status AS ENUM('ToDo', 'InProgress', 'Done', 'Archived') CREATE TABLE IF NOT EXISTS tickets ( id INTEGER PRIMARY KEY AUTOINCREMENT, category category NOT NULL DEFAULT 'Sonstiges', betreff VARCHAR(100), description VARCHAR, room SMALLINT, + status status NOT NULL DEFAULT 'ToDo', date TIMESTAMP, user_id SMALLINT );