1use crate::model::r#enum::fill_pattern_type::FillPatternType;
2use chrono::{NaiveDate, NaiveDateTime};
3use serde::{Deserialize, Serialize};
4use typeshare::typeshare;
5use utoipa::ToSchema;
6use uuid::Uuid;
7
8#[typeshare]
10#[derive(Debug, Clone, Deserialize, ToSchema, Serialize)]
11#[serde(rename_all = "camelCase")]
12pub struct DrawingDto {
13 pub id: Uuid,
14
15 pub variant: DrawingVariant,
16
17 pub layer_id: Uuid,
18 pub add_date: Option<NaiveDate>,
19 pub remove_date: Option<NaiveDate>,
20 pub rotation: i32,
21 pub scale_x: i32,
22 pub scale_y: i32,
23 pub x: i32,
24 pub y: i32,
25 pub notes: String,
26 pub created_at: Option<NaiveDateTime>,
27 pub modified_at: Option<NaiveDateTime>,
28 pub created_by: Option<Uuid>,
29 pub modified_by: Option<Uuid>,
30}
31
32#[typeshare]
34#[derive(Debug, Clone, Deserialize, ToSchema, Serialize)]
35#[serde(rename_all = "camelCase")]
36pub struct DrawingCreateDto {
37 pub id: Uuid,
38
39 pub variant: DrawingVariant,
40
41 pub layer_id: Uuid,
42 pub add_date: Option<NaiveDate>,
43 pub remove_date: Option<NaiveDate>,
44 pub rotation: i32,
45 pub scale_x: i32,
46 pub scale_y: i32,
47 pub x: i32,
48 pub y: i32,
49 pub notes: String,
50}
51
52#[typeshare]
53#[derive(Debug, Clone, Deserialize, ToSchema, Serialize)]
54#[serde(rename_all = "camelCase")]
55pub struct RectangleProperties {
56 pub width: i32,
57 pub height: i32,
58 pub color: String,
59 pub fill_pattern: FillPatternType,
60 pub stroke_width: i32,
61}
62
63#[typeshare]
64#[derive(Debug, Clone, Deserialize, ToSchema, Serialize)]
65#[serde(rename_all = "camelCase")]
66pub struct EllipseProperties {
67 pub radius_x: i32,
68 pub radius_y: i32,
69 pub color: String,
70 pub fill_pattern: FillPatternType,
71 pub stroke_width: i32,
72}
73
74#[typeshare]
75#[derive(Debug, Clone, Deserialize, ToSchema, Serialize)]
76#[serde(rename_all = "camelCase")]
77pub struct FreeLineProperties {
78 pub points: Vec<Vec<i32>>,
80 pub color: String,
81 pub fill_pattern: FillPatternType,
82 pub stroke_width: i32,
83}
84
85#[typeshare]
86#[derive(Debug, Clone, Deserialize, ToSchema, Serialize)]
87#[serde(rename_all = "camelCase")]
88pub struct PolygonProperties {
89 pub points: Vec<Vec<i32>>,
91 pub color: String,
92 pub fill_pattern: FillPatternType,
93 pub stroke_width: i32,
94}
95
96#[typeshare]
97#[derive(Debug, Clone, Deserialize, ToSchema, Serialize)]
98#[serde(rename_all = "camelCase")]
99pub struct LabelTextProperties {
100 pub text: String,
101 pub width: i32,
102 pub height: i32,
103 pub color: String,
104}
105
106#[typeshare]
107#[derive(Debug, Clone, Deserialize, ToSchema, Serialize)]
108#[serde(rename_all = "camelCase")]
109pub struct ImageProperties {
110 pub path: String,
111}
112
113#[typeshare]
115#[derive(Debug, Clone, Deserialize, ToSchema, Serialize)]
116#[serde(tag = "type", content = "properties")]
117pub enum DrawingVariant {
118 Rectangle(RectangleProperties),
119 Ellipse(EllipseProperties),
120 FreeLine(FreeLineProperties),
121 BezierPolygon(PolygonProperties),
122 LabelText(LabelTextProperties),
123 Image(ImageProperties),
124}
125
126#[typeshare]
128#[derive(Debug, Clone, Copy, Serialize, Deserialize, ToSchema)]
129#[serde(rename_all = "camelCase")]
130pub struct UpdateAddDateDrawingDto {
131 pub id: Uuid,
133 pub add_date: Option<NaiveDate>,
136}
137
138#[typeshare]
140#[derive(Debug, Clone, Copy, Serialize, Deserialize, ToSchema)]
141#[serde(rename_all = "camelCase")]
142pub struct UpdateRemoveDateDrawingDto {
143 pub id: Uuid,
145 pub remove_date: Option<NaiveDate>,
148}
149
150#[typeshare]
152#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
153#[serde(rename_all = "camelCase")]
154pub struct UpdateNotesDrawingDto {
155 pub id: Uuid,
157 pub notes: String,
159}
160
161#[typeshare]
166#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
167#[serde(tag = "type", content = "content")]
168pub enum UpdateDrawingsDto {
169 Update(Vec<DrawingDto>),
171 UpdateAddDate(Vec<UpdateAddDateDrawingDto>),
173 UpdateRemoveDate(Vec<UpdateRemoveDateDrawingDto>),
175 UpdateNotes(Vec<UpdateNotesDrawingDto>),
177}