use chrono::NaiveDate;
use serde::{Deserialize, Serialize};
use typeshare::typeshare;
use utoipa::ToSchema;
use uuid::Uuid;
#[typeshare]
#[derive(Debug, Clone, Deserialize, ToSchema, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct DrawingDto {
pub id: Uuid,
pub variant: DrawingVariant,
pub layer_id: Uuid,
pub add_date: Option<NaiveDate>,
pub remove_date: Option<NaiveDate>,
pub rotation: f32,
pub scale_x: f32,
pub scale_y: f32,
pub x: i32,
pub y: i32,
pub notes: String,
}
#[typeshare]
#[derive(Debug, Clone, Deserialize, ToSchema, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct RectangleProperties {
pub width: f32,
pub height: f32,
pub color: String,
pub fill_pattern: FillPatternType,
pub stroke_width: f32,
}
#[typeshare]
#[derive(Debug, Clone, Deserialize, ToSchema, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct EllipseProperties {
pub radius_x: f32,
pub radius_y: f32,
pub color: String,
pub fill_pattern: FillPatternType,
pub stroke_width: f32,
}
#[typeshare]
#[derive(Debug, Clone, Deserialize, ToSchema, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct FreeLineProperties {
pub points: Vec<Vec<f32>>,
pub color: String,
pub fill_pattern: FillPatternType,
pub stroke_width: f32,
}
#[typeshare]
#[derive(Debug, Clone, Deserialize, ToSchema, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PolygonProperties {
pub points: Vec<Vec<f32>>,
pub color: String,
pub fill_pattern: FillPatternType,
pub stroke_width: f32,
}
#[typeshare]
#[derive(Debug, Clone, Deserialize, ToSchema, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct LabelTextProperties {
pub text: String,
pub width: i32,
pub height: i32,
pub color: String,
}
#[typeshare]
#[derive(Debug, Clone, Deserialize, ToSchema, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct ImageProperties {
pub path: String,
}
#[typeshare]
#[derive(Debug, Clone, Deserialize, ToSchema, Serialize)]
#[serde(tag = "type", content = "properties")]
pub enum DrawingVariant {
Rectangle(RectangleProperties),
Ellipse(EllipseProperties),
FreeLine(FreeLineProperties),
BezierPolygon(PolygonProperties),
LabelText(LabelTextProperties),
Image(ImageProperties),
}
#[typeshare]
#[derive(Debug, Clone, Deserialize, Serialize)]
pub enum FillPatternType {
#[serde(rename = "fill")]
Fill,
#[serde(rename = "none")]
None,
#[serde(rename = "hatchdown")]
HatchDown,
#[serde(rename = "hatchup")]
HatchUp,
#[serde(rename = "crosshatch")]
CrossHatch,
#[serde(rename = "points")]
Points,
#[serde(rename = "wave")]
Wave,
}
#[typeshare]
#[derive(Debug, Clone, Copy, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct UpdateAddDateDrawingDto {
pub id: Uuid,
pub add_date: Option<NaiveDate>,
}
#[typeshare]
#[derive(Debug, Clone, Copy, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct UpdateRemoveDateDrawingDto {
pub id: Uuid,
pub remove_date: Option<NaiveDate>,
}
#[typeshare]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
#[serde(rename_all = "camelCase")]
pub struct UpdateNotesDrawingDto {
pub id: Uuid,
pub notes: String,
}
#[typeshare]
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
#[serde(tag = "type", content = "content")]
pub enum UpdateDrawingsDto {
Update(Vec<DrawingDto>),
UpdateAddDate(Vec<UpdateAddDateDrawingDto>),
UpdateRemoveDate(Vec<UpdateRemoveDateDrawingDto>),
UpdateNotes(Vec<UpdateNotesDrawingDto>),
}