As said, functions got implemented. Also minor changes to migration layout and dependencies
87 lines
2.1 KiB
Rust
87 lines
2.1 KiB
Rust
use std::fmt::Display;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
use sqlx::{Decode, prelude::Type};
|
|
|
|
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize, Decode, 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, Decode, 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 betreff: String,
|
|
pub description: String,
|
|
pub room: i16,
|
|
pub status: Status,
|
|
pub date: chrono::NaiveDateTime,
|
|
pub user_id: i16,
|
|
}
|
|
|
|
#[derive(Deserialize, Serialize, Debug, PartialEq)]
|
|
pub struct TicketResponse {
|
|
pub id: i32,
|
|
pub category: Category,
|
|
pub betreff: String,
|
|
pub description: String,
|
|
pub room: i16,
|
|
pub status: Status,
|
|
pub date: chrono::NaiveDateTime,
|
|
pub user_id: i16,
|
|
}
|
|
|
|
#[derive(Deserialize, Serialize, PartialEq, Debug)]
|
|
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,
|
|
}
|