Implemented data model, database schema and database connection pool.

This commit is contained in:
2023-08-24 22:06:37 +02:00
parent df247b3ed1
commit 7cb61cd38a
6 changed files with 192 additions and 3 deletions
+82
View File
@@ -0,0 +1,82 @@
use chrono::{NaiveDate, NaiveTime, Weekday};
use rust_decimal::Decimal;
use uuid::Uuid;
pub struct Company {
id: u16,
name: String,
street: String,
house_number: String,
zip_code: String,
city: String,
}
pub struct User {
id: u16,
login: String,
password: String,
full_name: String,
email: String,
admin: bool,
get_emails: bool,
}
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,
}
+26
View File
@@ -0,0 +1,26 @@
use cfg_if::cfg_if;
pub mod data;
cfg_if!{
if #[cfg(feature = "ssr")] {
use sqlx::PgPool;
#[derive(Clone)]
pub struct AppData {
db_pool: PgPool
}
impl AppData {
pub fn new(db_pool: PgPool) -> Self {
Self {
db_pool
}
}
pub fn db_pool(&self) -> &PgPool {
&self.db_pool
}
}
}
}