backend/model/entity/
layers.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
use chrono::NaiveDateTime;
use diesel::AsChangeset;
use diesel::{Identifiable, Insertable, Queryable};
use uuid::Uuid;

use crate::model::r#enum::layer_type::LayerType;
use crate::schema::layers;

/// The `Layer` entity.
#[derive(Identifiable, Queryable, Insertable)]
#[diesel(table_name = layers)]
pub struct Layer {
    /// The id of the map this layer belongs to.
    pub map_id: i32,
    /// The type of layer.
    pub type_: LayerType,
    /// The name of the layer.
    pub name: String,
    /// A flag indicating if this layer is an user created alternative.
    pub is_alternative: bool,
    /// The id of the layer.
    pub id: Uuid,
    /// Set if the layer has been soft-deleted
    pub marked_deleted: Option<NaiveDateTime>,
    /// Order within the map.
    pub order_index: i32,
}

/// Update `Layer` order index.
#[derive(AsChangeset, Identifiable)]
#[diesel(table_name = layers)]
pub struct UpdateLayerOrderIndex {
    /// The id of the layer.
    pub id: Uuid,
    /// New order index within the map.
    pub order_index: i32,
}

/// Update `Layer` name.
#[derive(AsChangeset, Identifiable)]
#[diesel(table_name = layers)]
pub struct UpdateLayerName {
    /// New layer name.
    pub name: String,
    /// The id of the layer.
    pub id: Uuid,
}

/// Update `Layer` name.
#[derive(AsChangeset, Identifiable)]
#[diesel(table_name = layers, treat_none_as_null = true)]
// #[diesel(treat_none_as_null = true)]
pub struct UpdateLayerMarkedDeleted {
    /// The id of the layer.
    pub id: Uuid,
    /// Whether the layer is marked for deletion.
    pub marked_deleted: Option<NaiveDateTime>,
}