Files
ticketsystem/backend/src/models.rs
2026-05-01 18:11:40 +02:00

98 lines
2.2 KiB
Rust

use std::fmt::Display;
use serde::{Deserialize, Serialize};
use sqlx::{Decode, prelude::Type};
#[derive(Deserialize, Serialize, PartialEq, Debug, sqlx::FromRow)]
pub struct Ticket {
pub id: i32,
pub category: String,
pub betreff: String,
pub description: String,
pub room: i16,
pub status: String,
pub date: chrono::DateTime<chrono::Utc>,
pub user_id: i16,
}
#[derive(Deserialize, Serialize, Debug, PartialEq)]
pub struct TicketResponse {
pub id: i32,
pub category: String,
pub betreff: String,
pub description: String,
pub room: i16,
pub status: String,
pub date: chrono::DateTime<chrono::Utc>,
pub user_id: i16,
pub user_first_name: String,
pub user_last_name: String,
}
#[derive(Deserialize, Serialize, PartialEq, Debug, Clone, sqlx::FromRow)]
pub struct User {
pub id: i16,
pub last_name: String,
pub first_name: String,
pub username: String,
pub is_admin: bool,
pub pwd: String,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct TicketCreateScheme {
pub category: String,
pub betreff: String,
pub description: String,
pub room: i16,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct TicketUpdateScheme {
pub status: String,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct UserUpdateScheme {
pub id: i16,
pub first_name: String,
pub last_name: String,
pub username: String,
pub make_admin: bool,
pub new_pwd: String,
}
#[derive(Deserialize, Serialize, Debug, sqlx::FromRow)]
pub struct UserCreateScheme {
pub first_name: String,
pub last_name: String,
pub username: String,
pub is_admin: bool,
pub pwd: String,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct LoginScheme {
pub username: String,
pub pwd: String,
}
#[derive(Debug, Clone, Serialize)]
pub struct FilteredUser {
pub id: i16,
pub first_name: String,
pub last_name: String,
pub username: String,
pub is_admin: bool,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct Claims {
#[serde(alias = "subject")]
pub sub: String,
#[serde(rename = "iat", alias = "issued", default)]
pub issued: usize,
#[serde(rename = "exp", alias = "expires", default)]
pub expires: usize,
}