koprogo_api/application/dto/
building_dto.rs1use serde::{Deserialize, Serialize};
2use validator::Validate;
3
4#[derive(Debug, Serialize, Deserialize, Validate, Clone)]
5pub struct CreateBuildingDto {
6 pub organization_id: String,
7
8 #[validate(length(min = 1, message = "Name cannot be empty"))]
9 pub name: String,
10
11 #[validate(length(min = 1))]
12 pub address: String,
13
14 #[validate(length(min = 1))]
15 pub city: String,
16
17 #[validate(length(min = 1))]
18 pub postal_code: String,
19
20 #[validate(length(min = 1))]
21 pub country: String,
22
23 #[validate(range(min = 1, message = "Total units must be greater than 0"))]
24 pub total_units: i32,
25
26 #[validate(range(min = 1, message = "Total tantiemes must be greater than 0"))]
27 pub total_tantiemes: Option<i32>,
28
29 pub construction_year: Option<i32>,
30}
31
32#[derive(Debug, Serialize, Deserialize, Validate, Clone)]
33pub struct UpdateBuildingDto {
34 pub organization_id: Option<String>, #[validate(length(min = 1))]
37 pub name: String,
38
39 #[validate(length(min = 1))]
40 pub address: String,
41
42 #[validate(length(min = 1))]
43 pub city: String,
44
45 #[validate(length(min = 1))]
46 pub postal_code: String,
47
48 #[validate(length(min = 1))]
49 pub country: String,
50
51 #[validate(range(min = 1, message = "Total units must be greater than 0"))]
52 pub total_units: i32,
53
54 #[validate(range(min = 1, message = "Total tantiemes must be greater than 0"))]
55 pub total_tantiemes: Option<i32>,
56
57 pub construction_year: Option<i32>,
58}
59
60#[derive(Debug, Serialize)]
61pub struct BuildingResponseDto {
62 pub id: String,
63 pub organization_id: String,
64 pub name: String,
65 pub address: String,
66 pub city: String,
67 pub postal_code: String,
68 pub country: String,
69 pub total_units: i32,
70 pub total_tantiemes: i32,
71 pub construction_year: Option<i32>,
72 pub created_at: String,
73 pub updated_at: String,
74}