Changed enums to string
String is easyer to decode and the sendable data in the frontend will be limited.
This commit is contained in:
@@ -24,7 +24,7 @@ pub async fn create_ticket(
|
|||||||
.bind(body.category.to_string())
|
.bind(body.category.to_string())
|
||||||
.bind(body.description.to_string())
|
.bind(body.description.to_string())
|
||||||
.bind(body.betreff.to_string())
|
.bind(body.betreff.to_string())
|
||||||
.bind(body.room.to_string())
|
.bind(body.room)
|
||||||
.execute(&data.db)
|
.execute(&data.db)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|||||||
@@ -3,56 +3,14 @@ use std::fmt::Display;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::{Decode, prelude::Type};
|
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)]
|
#[derive(Deserialize, Serialize, PartialEq, Debug, sqlx::FromRow)]
|
||||||
pub struct Ticket {
|
pub struct Ticket {
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
pub category: Category,
|
pub category: String,
|
||||||
pub betreff: String,
|
pub betreff: String,
|
||||||
pub description: String,
|
pub description: String,
|
||||||
pub room: i16,
|
pub room: i16,
|
||||||
pub status: Status,
|
pub status: String,
|
||||||
pub date: chrono::NaiveDateTime,
|
pub date: chrono::NaiveDateTime,
|
||||||
pub user_id: i16,
|
pub user_id: i16,
|
||||||
}
|
}
|
||||||
@@ -60,11 +18,11 @@ pub struct Ticket {
|
|||||||
#[derive(Deserialize, Serialize, Debug, PartialEq)]
|
#[derive(Deserialize, Serialize, Debug, PartialEq)]
|
||||||
pub struct TicketResponse {
|
pub struct TicketResponse {
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
pub category: Category,
|
pub category: String,
|
||||||
pub betreff: String,
|
pub betreff: String,
|
||||||
pub description: String,
|
pub description: String,
|
||||||
pub room: i16,
|
pub room: i16,
|
||||||
pub status: Status,
|
pub status: String,
|
||||||
pub date: chrono::NaiveDateTime,
|
pub date: chrono::NaiveDateTime,
|
||||||
pub user_id: i16,
|
pub user_id: i16,
|
||||||
}
|
}
|
||||||
@@ -79,7 +37,7 @@ pub struct User {
|
|||||||
|
|
||||||
#[derive(Deserialize, Serialize, Debug)]
|
#[derive(Deserialize, Serialize, Debug)]
|
||||||
pub struct TicketCreateScheme {
|
pub struct TicketCreateScheme {
|
||||||
pub category: Category,
|
pub category: String,
|
||||||
pub betreff: String,
|
pub betreff: String,
|
||||||
pub description: String,
|
pub description: String,
|
||||||
pub room: i16,
|
pub room: i16,
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
DROP TYPE category;
|
|
||||||
DROP TYPE status;
|
|
||||||
@@ -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');
|
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
CREATE TABLE IF NOT EXISTS tickets (
|
CREATE TABLE IF NOT EXISTS tickets (
|
||||||
id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
||||||
category category NOT NULL DEFAULT 'Sonstiges',
|
category VARCHAR(20) NOT NULL DEFAULT 'Sonstiges',
|
||||||
betreff VARCHAR(100),
|
betreff VARCHAR(100),
|
||||||
description TEXT,
|
description TEXT,
|
||||||
room SMALLINT,
|
room SMALLINT,
|
||||||
status status NOT NULL DEFAULT 'ToDo',
|
status VARCHAR(15) NOT NULL DEFAULT 'ToDo',
|
||||||
date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
user_id SMALLINT
|
user_id SMALLINT
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user