Changed enums to string

String is easyer to decode and the sendable data in the frontend will be
limited.
This commit is contained in:
2026-04-23 16:51:21 +02:00
parent d890255631
commit b905ffc9b1
5 changed files with 8 additions and 54 deletions

View File

@@ -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;

View File

@@ -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,