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: i64,
15    /// The type of layer.
16    pub type_: LayerType,
17    /// The name of the layer.
18    pub name: String,
19    /// The id of the layer.
20    pub id: Uuid,
21    /// Set if the layer has been soft-deleted
22    pub marked_deleted: Option<NaiveDateTime>,
23    /// Order within the map.
24    pub order_index: i32,
25}
26
27/// Update `Layer` order index.
28#[derive(AsChangeset, Identifiable)]
29#[diesel(table_name = layers)]
30pub struct UpdateLayerOrderIndex {
31    /// The id of the layer.
32    pub id: Uuid,
33    /// New order index within the map.
34    pub order_index: i32,
35}
36
37/// Update `Layer` name.
38#[derive(AsChangeset, Identifiable)]
39#[diesel(table_name = layers)]
40pub struct UpdateLayerName {
41    /// New layer name.
42    pub name: String,
43    /// The id of the layer.
44    pub id: Uuid,
45}
46
47/// Update `Layer` name.
48#[derive(AsChangeset, Identifiable)]
49#[diesel(table_name = layers, treat_none_as_null = true)]
50// #[diesel(treat_none_as_null = true)]
51pub struct UpdateLayerMarkedDeleted {
52    /// The id of the layer.
53    pub id: Uuid,
54    /// Whether the layer is marked for deletion.
55    pub marked_deleted: Option<NaiveDateTime>,
56}