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, +}