138 lines
4.7 KiB
Rust
138 lines
4.7 KiB
Rust
use chrono::NaiveDateTime;
|
|
use diesel::sql_types::{Jsonb, Nullable, SmallInt, Text, Timestamp, Uuid};
|
|
|
|
use crate::schema::eu_instances;
|
|
use crate::schema::eu_positions;
|
|
use crate::schema::eu_templates;
|
|
use crate::schema::eu_vehicle_positions;
|
|
use crate::schema::event_types;
|
|
use crate::schema::events;
|
|
|
|
#[derive(Queryable, Clone, Deserialize, Serialize, AsChangeset, Insertable, QueryableByName)]
|
|
#[table_name = "events"]
|
|
#[changeset_options(treat_none_as_null = "true")]
|
|
#[primary_key(entity_id)]
|
|
pub struct Event {
|
|
#[sql_type = "Uuid"]
|
|
pub(crate) entity_id: uuid::Uuid,
|
|
#[sql_type = "Text"]
|
|
pub(crate) name: String,
|
|
#[sql_type = "Timestamp"]
|
|
pub(crate) start: NaiveDateTime,
|
|
#[sql_type = "Timestamp"]
|
|
pub(crate) end: NaiveDateTime,
|
|
#[sql_type = "Nullable<Text>"]
|
|
pub(crate) site: Option<String>,
|
|
#[sql_type = "Nullable<Uuid>"]
|
|
pub(crate) organiser_id: Option<uuid::Uuid>,
|
|
#[sql_type = "Nullable<Uuid>"]
|
|
pub(crate) etype: Option<uuid::Uuid>,
|
|
#[sql_type = "Nullable<Text>"]
|
|
pub(crate) contact_on_site_name: Option<String>,
|
|
#[sql_type = "Nullable<Text>"]
|
|
pub(crate) contact_on_site_phone: Option<String>,
|
|
#[sql_type = "Nullable<Uuid>"]
|
|
pub(crate) member_responsible: Option<uuid::Uuid>,
|
|
#[sql_type = "Nullable<Uuid>"]
|
|
pub(crate) related_group: Option<uuid::Uuid>,
|
|
#[sql_type = "Nullable<Text>"]
|
|
pub(crate) other: Option<String>,
|
|
#[sql_type = "Nullable<Text>"]
|
|
pub(crate) other_intern: Option<String>,
|
|
#[sql_type = "Nullable<Uuid>"]
|
|
pub(crate) related_request: Option<uuid::Uuid>,
|
|
#[sql_type = "SmallInt"]
|
|
pub(crate) state: i16,
|
|
}
|
|
|
|
#[derive(Queryable, Clone, Deserialize, Serialize, AsChangeset, Insertable)]
|
|
#[table_name = "event_types"]
|
|
#[changeset_options(treat_none_as_null = "true")]
|
|
#[primary_key(type_id)]
|
|
pub struct EventType{
|
|
pub(crate) type_id: uuid::Uuid,
|
|
pub(crate) name: String,
|
|
pub(crate) description: Option<String>,
|
|
pub(crate) is_billable: bool,
|
|
}
|
|
|
|
#[derive(Queryable, Clone, Deserialize, Serialize, AsChangeset, Insertable)]
|
|
#[table_name = "eu_positions"]
|
|
#[changeset_options(treat_none_as_null = "true")]
|
|
#[primary_key(entity_id)]
|
|
pub struct EventUnitPosition{
|
|
pub(crate) entity_id: uuid::Uuid,
|
|
pub(crate) name: String,
|
|
pub(crate) description: Option<String>,
|
|
pub(crate) requirements: Option<serde_json::Value>,
|
|
}
|
|
|
|
#[derive(Queryable, Clone, Deserialize, Serialize, AsChangeset, Insertable)]
|
|
#[table_name = "eu_templates"]
|
|
#[changeset_options(treat_none_as_null = "true")]
|
|
#[primary_key(entity_id)]
|
|
pub struct EventUnitTemplate{
|
|
pub(crate) entity_id: uuid::Uuid,
|
|
pub(crate) name: String,
|
|
pub(crate) description: Option<String>,
|
|
}
|
|
|
|
#[derive(Queryable, Clone, Deserialize, Serialize, AsChangeset, Insertable)]
|
|
#[table_name = "eu_instances"]
|
|
#[changeset_options(treat_none_as_null = "true")]
|
|
#[primary_key(entity_id)]
|
|
#[deprecated]
|
|
pub struct EventUnitInstanceDeprecated {
|
|
pub(crate) instance_id: uuid::Uuid,
|
|
pub(crate) template_id: uuid::Uuid,
|
|
pub(crate) name: String,
|
|
pub(crate) event_id: uuid::Uuid,
|
|
}
|
|
|
|
#[derive(Queryable, Clone, Deserialize, Serialize, AsChangeset, Insertable)]
|
|
#[table_name = "eu_vehicle_positions"]
|
|
#[changeset_options(treat_none_as_null = "true")]
|
|
#[primary_key(entity_id)]
|
|
pub struct EventUnitVehiclePosition{
|
|
pub(crate) entity_id: uuid::Uuid,
|
|
pub(crate) name: String,
|
|
pub(crate) description: Option<String>,
|
|
pub(crate) required_vehicle_category: uuid::Uuid,
|
|
pub(crate) template_id: uuid::Uuid,
|
|
}
|
|
|
|
#[derive(Queryable, Clone, Deserialize, Serialize, QueryableByName)]
|
|
pub struct EventUnitInstancePosition{
|
|
#[sql_type = "Uuid"]
|
|
pub(crate) position_instance_id: uuid::Uuid,
|
|
#[sql_type = "Uuid"]
|
|
pub(crate) instance_id: uuid::Uuid,
|
|
#[sql_type = "Uuid"]
|
|
pub(crate) position_id: uuid::Uuid,
|
|
#[sql_type = "Nullable<Uuid>"]
|
|
pub(crate) taken_by: Option<uuid::Uuid>,
|
|
#[sql_type = "Text"]
|
|
pub(crate) name: String,
|
|
#[sql_type = "Nullable<Text>"]
|
|
pub(crate) description: Option<String>,
|
|
#[sql_type = "Nullable<Jsonb>"]
|
|
pub(crate) requirements: Option<serde_json::Value>
|
|
}
|
|
|
|
#[derive(Queryable, Clone, Deserialize, Serialize, QueryableByName)]
|
|
pub struct EventUnitInstanceVehiclePosition{
|
|
#[sql_type = "Uuid"]
|
|
pub(crate) position_instance_id: uuid::Uuid,
|
|
#[sql_type = "Uuid"]
|
|
pub(crate) instance_id: uuid::Uuid,
|
|
#[sql_type = "Uuid"]
|
|
pub(crate) position_id: uuid::Uuid,
|
|
#[sql_type = "Nullable<Uuid>"]
|
|
pub(crate) taken_by: Option<uuid::Uuid>,
|
|
#[sql_type = "Text"]
|
|
pub(crate) name: String,
|
|
#[sql_type = "Nullable<Text>"]
|
|
pub(crate) description: Option<String>,
|
|
#[sql_type = "Uuid"]
|
|
pub(crate) required_vehicle_category: uuid::Uuid,
|
|
} |