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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
//! All entities associated with [`Planting`].
use chrono::{NaiveDate, NaiveDateTime};
use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
use uuid::Uuid;
use crate::schema::plantings;
/// The `Planting` entity.
#[derive(Debug, Clone, Identifiable, Queryable)]
#[diesel(table_name = plantings)]
pub struct Planting {
/// The id of the planting.
pub id: Uuid,
/// The plant that is planted.
pub plant_id: i32,
/// The x coordinate of the position on the map.
pub x: i32,
/// The y coordinate of the position on the map.
pub y: i32,
/// The size of the planting on the map in x direction.
pub size_x: i32,
/// The size of the planting on the map in y direction.
pub size_y: i32,
/// The rotation in degrees (0-360) of the plant on the map.
pub rotation: f32,
/// The date the planting was added to the map.
/// If None, the planting always existed.
pub add_date: Option<NaiveDate>,
/// The date the planting was removed from the map.
/// If None, the planting is still on the map.
pub remove_date: Option<NaiveDate>,
/// Plantings may be linked with a seed.
pub seed_id: Option<i32>,
/// Is the planting an area of plantings.
pub is_area: bool,
/*
/// The date the planting was created.
//pub create_date: NaiveDate,
/// The date the planting was 'soft' deleted
/// and is still able to be restored.
//pub delete_date: Option<NaiveDate>,
*/
/// Notes about the planting in Markdown.
pub notes: String,
/// The datetime the planting was created.
pub created_at: NaiveDateTime,
/// The datetime the planting was last modified.
pub modified_at: NaiveDateTime,
/// The uuid of the user that created the planting.
pub created_by: Uuid,
/// The uuid of the user that last modified the planting.
pub modified_by: Uuid,
/// The plant layer the plantings is on.
pub layer_id: Uuid,
/// The height of the planting in cm (z direction).
pub height: Option<i32>,
}
/// The `NewPlanting` entity.
#[derive(Insertable)]
#[diesel(table_name = plantings)]
pub struct NewPlanting {
/// The id of the planting (set by the frontend)
pub id: Uuid,
/// The plant that is planted.
pub plant_id: i32,
/// The x coordinate of the position on the map.
pub x: i32,
/// The y coordinate of the position on the map.
pub y: i32,
/// The size of the planting on the map in x direction.
pub size_x: i32,
/// The size of the planting on the map in y direction.
pub size_y: i32,
/// The rotation in degrees (0-360) of the plant on the map.
pub rotation: f32,
/// The date the planting was added to the map.
/// If None, the planting always existed.
pub add_date: Option<NaiveDate>,
/// The date the planting was removed from the map.
/// If None, the planting is still on the map.
pub remove_date: Option<NaiveDate>,
/// Plantings may be linked with a seed.
pub seed_id: Option<i32>,
/// Is the planting an area of plants.
pub is_area: bool,
/// The uuid of the user that created the planting.
pub created_by: Uuid,
/// The user who last modified the planting.
pub modified_by: Uuid,
/// The plant layer the plantings is on.
pub layer_id: Uuid,
/// The height of the planting in cm (z direction).
pub height: Option<i32>,
}
/// The `UpdatePlanting` entity.
#[derive(Debug, Clone, Default, AsChangeset)]
#[diesel(table_name = plantings)]
pub struct UpdatePlanting {
/// The id of the planting.
/// This is not updated.
pub id: Uuid,
/// The x coordinate of the position on the map.
pub x: Option<i32>,
/// The y coordinate of the position on the map.
pub y: Option<i32>,
/// The size of the planting on the map in x direction.
pub size_x: Option<i32>,
/// The size of the planting on the map in y direction.
pub size_y: Option<i32>,
/// The rotation of the plant on the map.
pub rotation: Option<f32>,
/// The date the planting was added to the map.
pub add_date: Option<Option<NaiveDate>>,
/// The date the planting was removed from the map.
pub remove_date: Option<Option<NaiveDate>>,
/// Plantings may be linked with a seed.
pub seed_id: Option<i32>,
/// Notes about the planting in Markdown.
pub notes: Option<String>,
/// The height of the planting in cm (z direction).
pub height: Option<Option<i32>>,
}