From ed8e9af9d9eb650abf0d1de493d22565a312faa1 Mon Sep 17 00:00:00 2001 From: Franklin Date: Tue, 14 Mar 2023 21:13:24 -0400 Subject: [PATCH] Types v1 --- src/domain/agent.rs | 1 - src/domain/project.rs | 8 +++++++- src/dto/filters.rs | 16 ++++++++++++++++ src/dto/mod.rs | 1 + 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 src/dto/filters.rs diff --git a/src/domain/agent.rs b/src/domain/agent.rs index 0416445..14321b9 100644 --- a/src/domain/agent.rs +++ b/src/domain/agent.rs @@ -16,7 +16,6 @@ pub struct Agent { #[serde(rename = "credentialType")] pub credential_type: CredentialType, - #[serde(rename = "timeCreated")] pub time_created: DateTime, #[serde(rename = "lastUpdated")] diff --git a/src/domain/project.rs b/src/domain/project.rs index 74c663a..bcc6dd8 100644 --- a/src/domain/project.rs +++ b/src/domain/project.rs @@ -2,12 +2,15 @@ use chrono::{DateTime, Utc}; use serde::{Serialize, Deserialize}; use uuid::Uuid; -use super::media::MediaList; +use super::{media::MediaList, project_type::ProjectType}; #[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq, Eq, PartialOrd, Ord)] pub struct Project { pub id: Uuid, + #[serde(rename = "projectType")] + pub project_type: ProjectType, + #[serde(rename = "agentId")] pub agent_id: Uuid, #[serde(rename = "locationId")] @@ -16,6 +19,9 @@ pub struct Project { /// Title is optional as the agent can choose not to put the title there (in that case the title will be generated in the frontend) pub title: Option, pub description: String, + + #[serde(rename = "adminTag", skip_serializing_if = "Option::is_none")] + pub admin_tag: Option, /// Amount of floors the building/house has pub floors: i16, diff --git a/src/dto/filters.rs b/src/dto/filters.rs new file mode 100644 index 0000000..03c4e38 --- /dev/null +++ b/src/dto/filters.rs @@ -0,0 +1,16 @@ +use serde::{Deserialize, Serialize}; + +use crate::domain::project_type::ProjectType; + + +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, PartialOrd)] +pub enum Filter { + CheaperThan(f64), + MoreExpensiveThan(f64), + + InCity(String), + InDistrict(String), + + Finished, + ByProjectType(ProjectType), +} \ No newline at end of file diff --git a/src/dto/mod.rs b/src/dto/mod.rs index e69de29..994d55f 100644 --- a/src/dto/mod.rs +++ b/src/dto/mod.rs @@ -0,0 +1 @@ +pub mod filters; \ No newline at end of file