Files
rezervovator/src/backend/data.rs
T

110 lines
2.1 KiB
Rust
Raw Normal View History

2023-09-22 21:26:13 +02:00
//use chrono::{NaiveDate, NaiveTime, Weekday};
//use rust_decimal::Decimal;
use serde::{Deserialize, Serialize};
2023-09-22 21:26:13 +02:00
//use uuid::Uuid;
use validator::Validate;
2023-09-22 21:26:13 +02:00
#[derive(Serialize, Deserialize, Clone, Debug)]
pub enum ApiResponse<T> {
Data(T),
Error(String)
}
2023-09-15 13:55:01 +02:00
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, Validate, Default)]
#[cfg_attr(feature = "ssr", derive(sqlx::FromRow))]
pub struct Company {
id: i32,
#[validate(length(min = 1,message = "Name cannot be empty"))]
pub name: String,
#[validate(length(min = 1,message = "Street cannot be empty"))]
pub street: String,
#[validate(length(min = 1,message = "House number cannot be empty"))]
pub house_number: String,
pub zip_code: String,
pub city: String,
}
impl Company {
pub fn id(&self) -> i32 {
self.id
}
}
2023-09-22 21:26:13 +02:00
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, Validate, Default)]
#[cfg_attr(feature = "ssr", derive(sqlx::FromRow))]
pub struct User {
2023-09-22 21:26:13 +02:00
id: i32,
pub login: String,
pub password: String,
pub full_name: Option<String>,
pub email: Option<String>,
pub admin: bool,
pub get_emails: bool,
}
impl User {
pub fn id(&self) -> i32 {
self.id
}
}
2023-09-22 21:26:13 +02:00
/*pub struct Property {
id: u16,
name: String,
description: String,
price: Decimal
}
pub enum MessageType {
NewReservation,
NewReservationCust,
ReservationApp,
ReservationCanceled,
}
pub struct Message {
id: u16,
msg_type: MessageType,
subject: String,
text: String,
}
pub struct OpeningHour {
id: u16,
day: Weekday,
from: NaiveTime,
to: NaiveTime,
discount: u8
}
pub struct Customer {
id: u128,
full_name: String,
email: String,
phone: String,
discount: u8
}
pub enum ReservationState {
New,
Approved,
Canceled,
}
pub struct Reservation {
id: u128,
from: NaiveTime,
to: NaiveTime,
property: Property,
}
pub struct ReservationSum {
id: u128,
uuid: Uuid,
date: NaiveDate,
items: Vec<Reservation>,
customer: Customer,
price: Decimal,
state: ReservationState,
2023-09-22 21:26:13 +02:00
}*/