From a9e31e2fdf19b31dd377340950b74db97868c77f Mon Sep 17 00:00:00 2001 From: schn33fuchs Date: Wed, 22 Apr 2026 18:29:56 +0200 Subject: [PATCH] Implemeted Display trait for Category enum --- backend/src/main.rs | 7 +++++++ backend/src/models.rs | 31 +++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/backend/src/main.rs b/backend/src/main.rs index 16b6ebd..f627dc9 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -1,10 +1,17 @@ +mod handlers; mod models; +mod router; use axum::{Router, routing}; use dotenv::dotenv; use models::*; +use router::create_router; use serde::{Deserialize, Serialize}; use sqlx::{PgPool, postgres::PgPoolOptions}; +pub struct AppState { + db: PgPool, +} + #[tokio::main] async fn main() { dotenv().ok(); diff --git a/backend/src/models.rs b/backend/src/models.rs index c2e73cc..5a4e96f 100644 --- a/backend/src/models.rs +++ b/backend/src/models.rs @@ -1,7 +1,9 @@ +use std::fmt::Display; + use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] -pub enum category { +pub enum Category { WhiteboardBeamer, Internet, IPadKoffer, @@ -10,10 +12,23 @@ pub enum category { Sonstiges, } +impl Display for Category { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Self::WhiteboardBeamer => write!(f, "Whiteboard Beamer"), + Self::Internet => write!(f, "Internet"), + Self::IPadKoffer => write!(f, "IPad Koffer"), + Self::AppleTV => write!(f, "Apple TV"), + Self::DocuCam => write!(f, "Docu Cam"), + Self::Sonstiges => write!(f, "Sonstiges"), + } + } +} + #[derive(Deserialize, Serialize, PartialEq, Debug)] -pub struct ticket { +pub struct Ticket { pub id: i32, - pub category: category, + pub category: Category, pub betreff: String, pub description: String, pub room: i16, @@ -22,9 +37,17 @@ pub struct ticket { } #[derive(Deserialize, Serialize, PartialEq, Debug)] -pub struct user { +pub struct User { pub id: i16, pub first_name: String, pub last_name: String, pub is_admin: bool, } + +#[derive(Deserialize, Serialize, Debug)] +pub struct TicketCreateScheme { + pub category: Category, + pub betreff: String, + pub description: String, + pub room: i16, +}