backend/model/entity/
layers.rs

1use chrono::NaiveDateTime;
2use diesel::AsChangeset;
3use diesel::{Identifiable, Insertable, Queryable};
4use uuid::Uuid;
5
6use crate::model::r#enum::layer_type::LayerType;
7use crate::schema::layers;
8
9/// The `Layer` entity.
10#[derive(Identifiable, Queryable, Insertable)]
11#[diesel(table_name = layers)]
12pub struct Layer {
13    /// The id of the map this layer belongs to.
14    pub map_id: i32,
15    /// The type of layer.
16    pub type_: LayerType,
17    /// The name of the layer.
18    pub name: String,
19    /// A flag indicating if this layer is an user created alternative.
20    pub is_alternative: bool,
21    /// The id of the layer.
22    pub id: Uuid,
23    /// Set if the layer has been soft-deleted
24    pub marked_deleted: Option<NaiveDateTime>,
25    /// Order within the map.
26    pub order_index: i32,
27}
28
29/// Update `Layer` order index.
30#[derive(AsChangeset, Identifiable)]
31#[diesel(table_name = layers)]
32pub struct UpdateLayerOrderIndex {
33    /// The id of the layer.
34    pub id: Uuid,
35    /// New order index within the map.
36    pub order_index: i32,
37}
38
39/// Update `Layer` name.
40#[derive(AsChangeset, Identifiable)]
41#[diesel(table_name = layers)]
42pub struct UpdateLayerName {
43    /// New layer name.
44    pub name: String,
45    /// The id of the layer.
46    pub id: Uuid,
47}
48
49/// Update `Layer` name.
50#[derive(AsChangeset, Identifiable)]
51#[diesel(table_name = layers, treat_none_as_null = true)]
52// #[diesel(treat_none_as_null = true)]
53pub struct UpdateLayerMarkedDeleted {
54    /// The id of the layer.
55    pub id: Uuid,
56    /// Whether the layer is marked for deletion.
57    pub marked_deleted: Option<NaiveDateTime>,
58}