Implemeted Display trait for Category enum
This commit is contained in:
@@ -1,10 +1,17 @@
|
|||||||
|
mod handlers;
|
||||||
mod models;
|
mod models;
|
||||||
|
mod router;
|
||||||
use axum::{Router, routing};
|
use axum::{Router, routing};
|
||||||
use dotenv::dotenv;
|
use dotenv::dotenv;
|
||||||
use models::*;
|
use models::*;
|
||||||
|
use router::create_router;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sqlx::{PgPool, postgres::PgPoolOptions};
|
use sqlx::{PgPool, postgres::PgPoolOptions};
|
||||||
|
|
||||||
|
pub struct AppState {
|
||||||
|
db: PgPool,
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
dotenv().ok();
|
dotenv().ok();
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
|
||||||
pub enum category {
|
pub enum Category {
|
||||||
WhiteboardBeamer,
|
WhiteboardBeamer,
|
||||||
Internet,
|
Internet,
|
||||||
IPadKoffer,
|
IPadKoffer,
|
||||||
@@ -10,10 +12,23 @@ pub enum category {
|
|||||||
Sonstiges,
|
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)]
|
#[derive(Deserialize, Serialize, PartialEq, Debug)]
|
||||||
pub struct ticket {
|
pub struct Ticket {
|
||||||
pub id: i32,
|
pub id: i32,
|
||||||
pub category: category,
|
pub category: Category,
|
||||||
pub betreff: String,
|
pub betreff: String,
|
||||||
pub description: String,
|
pub description: String,
|
||||||
pub room: i16,
|
pub room: i16,
|
||||||
@@ -22,9 +37,17 @@ pub struct ticket {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, PartialEq, Debug)]
|
#[derive(Deserialize, Serialize, PartialEq, Debug)]
|
||||||
pub struct user {
|
pub struct User {
|
||||||
pub id: i16,
|
pub id: i16,
|
||||||
pub first_name: String,
|
pub first_name: String,
|
||||||
pub last_name: String,
|
pub last_name: String,
|
||||||
pub is_admin: bool,
|
pub is_admin: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize, Debug)]
|
||||||
|
pub struct TicketCreateScheme {
|
||||||
|
pub category: Category,
|
||||||
|
pub betreff: String,
|
||||||
|
pub description: String,
|
||||||
|
pub room: i16,
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user