Added status Struct

This commit is contained in:
2026-04-22 18:45:02 +02:00
parent a9e31e2fdf
commit 1725d2538c
2 changed files with 23 additions and 2 deletions

View File

@@ -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 struct Ticket {
pub id: i32, pub id: i32,
pub category: Category, pub category: Category,
pub betreff: String, pub betreff: String,
pub description: String, pub description: String,
pub room: i16, pub room: i16,
pub status: Status,
pub date: chrono::NaiveDateTime, pub date: chrono::NaiveDateTime,
pub user_id: i16, pub user_id: i16,
} }

View File

@@ -1,11 +1,12 @@
CREATE TYPE category AS ENUM('Whiteboard Beamer', 'Internet', 'iPad Koffer', 'Apple TV', 'Docu Cam', 'Sonstiges') 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 ( CREATE TABLE IF NOT EXISTS tickets (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
category category NOT NULL DEFAULT 'Sonstiges', category category NOT NULL DEFAULT 'Sonstiges',
betreff VARCHAR(100), betreff VARCHAR(100),
description VARCHAR, description VARCHAR,
room SMALLINT, room SMALLINT,
status status NOT NULL DEFAULT 'ToDo',
date TIMESTAMP, date TIMESTAMP,
user_id SMALLINT user_id SMALLINT
); );