1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use commonwasm::store::{build_exp_link, get};
use uuid::Uuid;
use crate::dto::building_response::BuildingResponse;
use crate::dto::building_with_floors_response::BuildingWithFloorsResponse;

const DOMAIN: &str = "property";
const CLUSTER: &str = "172.17.0.1:12610";
const SUFFIX: &str = "";

pub struct BuildingStore {}

impl BuildingStore  {
    pub async fn build_ws_link(project: impl Into<String>, url: impl Into<String>) -> String {
        format!("{}://{}{}{}{}", "https", project.into(), SUFFIX, CLUSTER, url.into())
    }
    pub async fn get_by_id(id: Uuid) -> Result<BuildingResponse, String> {
     //   get::<BuildingResponse>(Self::build_ws_link(DOMAIN, format!("/building/{}", id)).await).await
        get::<BuildingResponse>(format!("http://172.17.0.1:12610/building/{}",id)).await
    }

    pub async fn get_with_floors_by_id(building_id: Uuid) -> Result<BuildingWithFloorsResponse, String> {
     //   get::<BuildingWithFloorsResponse>(Self::build_ws_link(DOMAIN, format!("/building/findWithFloors/{}", building_id)).await).await
        get::<BuildingWithFloorsResponse>(format!("http://172.17.0.1:12610/building/findWithFloors/{}",building_id)).await
    }
}