use chrono::NaiveDate;
use diesel::{AsChangeset, Identifiable, Insertable, Queryable};
use postgis_diesel::types::{Point, Polygon};
use uuid::Uuid;
use crate::{
model::r#enum::{
shade::Shade, soil_texture::SoilTextureEnum, water_requirement::WaterRequirementEnum,
},
schema::{hydrologies, shadings, soil_textures},
};
#[derive(Debug, Clone, Identifiable, Queryable, Insertable)]
#[diesel(table_name = shadings)]
pub struct Shading {
pub id: Uuid,
pub layer_id: Uuid,
pub shade: Shade,
pub geometry: Polygon<Point>,
pub add_date: Option<NaiveDate>,
pub remove_date: Option<NaiveDate>,
pub notes: String,
}
#[derive(Debug, Clone, Default, AsChangeset)]
#[diesel(table_name = shadings)]
pub struct UpdateShading {
pub id: Uuid,
pub shade: Option<Shade>,
pub geometry: Option<Polygon<Point>>,
pub add_date: Option<Option<NaiveDate>>,
pub remove_date: Option<Option<NaiveDate>>,
pub notes: Option<String>,
}
#[derive(Debug, Clone, Identifiable, Queryable, Insertable)]
#[diesel(table_name = hydrologies)]
pub struct Hydrology {
pub id: Uuid,
pub layer_id: Uuid,
pub water_requirement: WaterRequirementEnum,
pub geometry: Polygon<Point>,
pub add_date: Option<NaiveDate>,
pub remove_date: Option<NaiveDate>,
pub notes: String,
}
#[derive(Debug, Clone, Default, AsChangeset)]
#[diesel(table_name = hydrologies)]
pub struct UpdateHydrology {
pub id: Uuid,
pub water_requirement: Option<WaterRequirementEnum>,
pub geometry: Option<Polygon<Point>>,
pub add_date: Option<Option<NaiveDate>>,
pub remove_date: Option<Option<NaiveDate>>,
pub notes: Option<String>,
}
#[derive(Debug, Clone, Identifiable, Queryable, Insertable)]
#[diesel(table_name = soil_textures)]
pub struct SoilTexture {
pub id: Uuid,
pub layer_id: Uuid,
pub soil_texture: SoilTextureEnum,
pub geometry: Polygon<Point>,
pub add_date: Option<NaiveDate>,
pub remove_date: Option<NaiveDate>,
pub notes: String,
}
#[derive(Debug, Clone, Default, AsChangeset)]
#[diesel(table_name = soil_textures)]
pub struct UpdateSoilTexture {
pub id: Uuid,
pub soil_texture: Option<SoilTextureEnum>,
pub geometry: Option<Polygon<Point>>,
pub add_date: Option<Option<NaiveDate>>,
pub remove_date: Option<Option<NaiveDate>>,
pub notes: Option<String>,
}