koprogo_api/application/dto/
unit_dto.rs1use crate::domain::entities::UnitType;
2use serde::{Deserialize, Serialize};
3use validator::Validate;
4
5#[derive(Debug, Deserialize, Validate, Clone)]
6pub struct CreateUnitDto {
7 pub organization_id: String,
8 pub building_id: String,
9
10 #[validate(length(min = 1))]
11 pub unit_number: String,
12
13 pub unit_type: UnitType,
14 pub floor: Option<i32>,
15
16 #[validate(range(min = 0.1))]
17 pub surface_area: f64,
18
19 #[validate(range(min = 0.1, max = 1000.0))]
20 pub quota: f64,
21}
22
23#[derive(Debug, Serialize)]
24pub struct UnitResponseDto {
25 pub id: String,
26 pub building_id: String,
27 pub unit_number: String,
28 pub unit_type: UnitType,
29 pub floor: Option<i32>,
30 pub surface_area: f64,
31 pub quota: f64,
32 pub owner_id: Option<String>,
33}