diff --git a/backend/src/handlers/ticket.rs b/backend/src/handlers/ticket.rs index 6693d31..cb31d38 100644 --- a/backend/src/handlers/ticket.rs +++ b/backend/src/handlers/ticket.rs @@ -24,7 +24,7 @@ pub async fn create_ticket( .bind(body.category.to_string()) .bind(body.description.to_string()) .bind(body.betreff.to_string()) - .bind(body.room.to_string()) + .bind(body.room) .execute(&data.db) .await; diff --git a/backend/src/models.rs b/backend/src/models.rs index 4039236..7365775 100644 --- a/backend/src/models.rs +++ b/backend/src/models.rs @@ -3,56 +3,14 @@ use std::fmt::Display; use serde::{Deserialize, Serialize}; use sqlx::{Decode, prelude::Type}; -#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, Type)] -pub enum Category { - WhiteboardBeamer, - Internet, - IPadKoffer, - AppleTV, - DocuCam, - 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(Clone, Debug, PartialEq, Deserialize, Serialize, Type)] -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 category: String, pub betreff: String, pub description: String, pub room: i16, - pub status: Status, + pub status: String, pub date: chrono::NaiveDateTime, pub user_id: i16, } @@ -60,11 +18,11 @@ pub struct Ticket { #[derive(Deserialize, Serialize, Debug, PartialEq)] pub struct TicketResponse { pub id: i32, - pub category: Category, + pub category: String, pub betreff: String, pub description: String, pub room: i16, - pub status: Status, + pub status: String, pub date: chrono::NaiveDateTime, pub user_id: i16, } @@ -79,7 +37,7 @@ pub struct User { #[derive(Deserialize, Serialize, Debug)] pub struct TicketCreateScheme { - pub category: Category, + pub category: String, pub betreff: String, pub description: String, pub room: i16, diff --git a/migrations/20260422094704_types.down.sql b/migrations/20260422094704_types.down.sql deleted file mode 100644 index 9fca44c..0000000 --- a/migrations/20260422094704_types.down.sql +++ /dev/null @@ -1,2 +0,0 @@ -DROP TYPE category; -DROP TYPE status; diff --git a/migrations/20260422094704_types.up.sql b/migrations/20260422094704_types.up.sql deleted file mode 100644 index 4ed4011..0000000 --- a/migrations/20260422094704_types.up.sql +++ /dev/null @@ -1,2 +0,0 @@ -CREATE TYPE category AS ENUM('Whiteboard Beamer', 'Internet', 'iPad Koffer', 'Apple TV', 'Docu Cam', 'Sonstiges'); -CREATE TYPE status AS ENUM('ToDo', 'InProgress', 'Done', 'Archived'); diff --git a/migrations/20260422094706_ticket_table.sql b/migrations/20260422094706_ticket_table.sql index c44c931..6f08af4 100644 --- a/migrations/20260422094706_ticket_table.sql +++ b/migrations/20260422094706_ticket_table.sql @@ -1,10 +1,10 @@ CREATE TABLE IF NOT EXISTS tickets ( id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, - category category NOT NULL DEFAULT 'Sonstiges', + category VARCHAR(20) NOT NULL DEFAULT 'Sonstiges', betreff VARCHAR(100), description TEXT, room SMALLINT, - status status NOT NULL DEFAULT 'ToDo', + status VARCHAR(15) NOT NULL DEFAULT 'ToDo', date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, user_id SMALLINT );