172 lines
4.8 KiB
Rust
172 lines
4.8 KiB
Rust
use diesel::prelude::*;
|
|
|
|
#[derive(Queryable, Selectable, Associations)]
|
|
#[diesel(belongs_to(User, foreign_key=worker_user_id))]
|
|
#[diesel(table_name = super::schema::clients)]
|
|
#[diesel(check_for_backend(diesel::pg::Pg))]
|
|
pub struct Client {
|
|
pub id: i64,
|
|
pub email: String,
|
|
pub first_name: String,
|
|
pub last_name: String,
|
|
pub date_of_birth: time::Date,
|
|
pub phone_number: String,
|
|
pub gov_id_number: String,
|
|
pub house_number: String,
|
|
pub address_line: String,
|
|
pub city: String,
|
|
pub state: String,
|
|
pub postal_code: String,
|
|
pub country: String,
|
|
pub worker_user_id: Option<i64>,
|
|
}
|
|
|
|
#[derive(Queryable, Selectable, Associations)]
|
|
#[diesel(belongs_to(User))]
|
|
#[diesel(belongs_to(Warehouse))]
|
|
#[diesel(table_name = super::schema::assigned_warehouse_managers)]
|
|
#[diesel(check_for_backend(diesel::pg::Pg))]
|
|
pub struct AssignedWarehouseManager {
|
|
pub id: i64,
|
|
pub user_id: i64,
|
|
pub warehouse_id: i64,
|
|
pub assigned_at: time::OffsetDateTime,
|
|
}
|
|
|
|
#[derive(Queryable, Selectable, Associations)]
|
|
#[diesel(belongs_to(User))]
|
|
#[diesel(table_name = super::schema::attachments)]
|
|
#[diesel(check_for_backend(diesel::pg::Pg))]
|
|
pub struct Attachment {
|
|
pub id: i64,
|
|
pub user_id: i64,
|
|
pub comment_id: i64,
|
|
pub created_at: time::OffsetDateTime,
|
|
}
|
|
|
|
#[derive(Queryable, Selectable, Associations)]
|
|
#[diesel(belongs_to(Warehouse))]
|
|
#[diesel(belongs_to(InventoryCatalogEntry, foreign_key=catalog_id))]
|
|
#[diesel(table_name = super::schema::inventory)]
|
|
#[diesel(check_for_backend(diesel::pg::Pg))]
|
|
pub struct Inventory {
|
|
pub id: i64,
|
|
pub warehouse_id: i64,
|
|
pub catalog_id: i64,
|
|
pub count: i64
|
|
}
|
|
|
|
#[derive(Queryable, Selectable)]
|
|
#[diesel(table_name = super::schema::inventory_catalog)]
|
|
#[diesel(check_for_backend(diesel::pg::Pg))]
|
|
pub struct InventoryCatalogEntry {
|
|
pub id: i64,
|
|
pub name: String,
|
|
pub code: String,
|
|
pub description: Option<String>,
|
|
pub created_at: time::OffsetDateTime,
|
|
}
|
|
|
|
#[derive(Queryable, Selectable, Associations)]
|
|
#[diesel(belongs_to(Client))]
|
|
#[diesel(table_name = super::schema::invoices)]
|
|
#[diesel(check_for_backend(diesel::pg::Pg))]
|
|
pub struct Invoice {
|
|
pub id: i64,
|
|
pub client_id: i64,
|
|
pub amount: f32
|
|
}
|
|
|
|
#[derive(Queryable, Selectable)]
|
|
#[diesel(table_name = super::schema::service_catalog)]
|
|
#[diesel(check_for_backend(diesel::pg::Pg))]
|
|
pub struct ServiceCatalogEntry {
|
|
pub id: i64,
|
|
pub name: String,
|
|
pub description: Option<String>,
|
|
pub value_string: Option<String>,
|
|
pub created_at: time::OffsetDateTime,
|
|
}
|
|
|
|
#[derive(Queryable, Selectable, Associations)]
|
|
#[diesel(belongs_to(Client))]
|
|
#[diesel(belongs_to(ServiceCatalogEntry, foreign_key=catalog_id))]
|
|
#[diesel(table_name = super::schema::assigned_services)]
|
|
#[diesel(check_for_backend(diesel::pg::Pg))]
|
|
pub struct AssignedService {
|
|
pub id: i64,
|
|
pub client_id: i64,
|
|
pub catalog_id: i64,
|
|
}
|
|
|
|
#[derive(Queryable, Selectable, Associations)]
|
|
#[diesel(belongs_to(User))]
|
|
#[diesel(belongs_to(Ticket))]
|
|
#[diesel(table_name = super::schema::ticket_comments)]
|
|
#[diesel(check_for_backend(diesel::pg::Pg))]
|
|
pub struct TicketComment {
|
|
pub id: i64,
|
|
pub user_id: i64,
|
|
pub ticket_id: i64,
|
|
pub created_at: time::OffsetDateTime,
|
|
pub modified_at: Option<time::OffsetDateTime>,
|
|
pub content: Option<String>
|
|
}
|
|
|
|
#[derive(Queryable, Selectable, Associations)]
|
|
#[diesel(belongs_to(AssignedService, foreign_key=service_id))]
|
|
#[diesel(table_name = super::schema::tickets)]
|
|
#[diesel(check_for_backend(diesel::pg::Pg))]
|
|
pub struct Ticket {
|
|
pub id: i64,
|
|
pub title: String,
|
|
pub description: Option<String>,
|
|
pub created_at: time::OffsetDateTime,
|
|
pub created_by_user_id: i64,
|
|
pub service_id: i64
|
|
}
|
|
|
|
#[derive(Queryable, Selectable)]
|
|
#[diesel(table_name = super::schema::users)]
|
|
#[diesel(check_for_backend(diesel::pg::Pg))]
|
|
pub struct User {
|
|
pub id: i64,
|
|
pub username: String,
|
|
pub email: String,
|
|
pub password_hash: String,
|
|
pub password_salt: String,
|
|
pub first_name: String,
|
|
pub last_name: String,
|
|
pub display_name: Option<String>,
|
|
pub date_of_birth: Option<time::Date>,
|
|
pub phone_number: Option<String>,
|
|
pub created_at: time::OffsetDateTime,
|
|
pub last_login_at: Option<time::OffsetDateTime>,
|
|
pub permissions: i64,
|
|
}
|
|
|
|
#[derive(Queryable, Selectable, Associations)]
|
|
#[diesel(belongs_to(User))]
|
|
#[diesel(belongs_to(Warehouse))]
|
|
#[diesel(table_name = super::schema::warehouse_actions)]
|
|
#[diesel(check_for_backend(diesel::pg::Pg))]
|
|
pub struct WarehouseAction {
|
|
pub id: i64,
|
|
pub user_id: i64,
|
|
pub warehouse_id: i64,
|
|
pub count: i64,
|
|
pub reason: String,
|
|
pub timestamp: time::OffsetDateTime,
|
|
}
|
|
|
|
#[derive(Queryable, Selectable)]
|
|
#[diesel(table_name = super::schema::warehouses)]
|
|
#[diesel(check_for_backend(diesel::pg::Pg))]
|
|
pub struct Warehouse {
|
|
pub id: i64,
|
|
pub name: String,
|
|
pub created_at: time::OffsetDateTime,
|
|
}
|
|
|
|
|