Added get unit with id
This commit is contained in:
parent
a9d6545322
commit
39510e0a9d
@ -53,7 +53,8 @@ pub async fn start_all_routes(start_time: i64, db_conn: Arc<PgPool>) -> Result<(
|
|||||||
.service(super::read::create_contact_request)
|
.service(super::read::create_contact_request)
|
||||||
.service(super::read::get_agent_with_shortcode)
|
.service(super::read::get_agent_with_shortcode)
|
||||||
.service(super::read::get_location_with_city_and_district)
|
.service(super::read::get_location_with_city_and_district)
|
||||||
.service(super::read::get_agent_with_id),
|
.service(super::read::get_agent_with_id)
|
||||||
|
.service(super::read::get_unit_with_id),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.bind((HOST_ADDR, HOST_PORT))?
|
.bind((HOST_ADDR, HOST_PORT))?
|
||||||
|
@ -14,7 +14,7 @@ use err::MessageResource;
|
|||||||
use jl_types::{
|
use jl_types::{
|
||||||
domain::{
|
domain::{
|
||||||
agent::Agent, location::Location, project_condition::ProjectCondition,
|
agent::Agent, location::Location, project_condition::ProjectCondition,
|
||||||
project_type::ProjectType,
|
project_type::ProjectType, unit::Unit,
|
||||||
},
|
},
|
||||||
dto::{
|
dto::{
|
||||||
filters::Filter, listing::Listing, payloads::contact::ContactPayload,
|
filters::Filter, listing::Listing, payloads::contact::ContactPayload,
|
||||||
@ -44,6 +44,14 @@ pub async fn get_agent_with_shortcode(
|
|||||||
services::read::get_agent_with_shortcode(&db_conn, &shortcode).await
|
services::read::get_agent_with_shortcode(&db_conn, &shortcode).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[get("/unit/{id}")]
|
||||||
|
pub async fn get_unit_with_id(
|
||||||
|
db_conn: web::Data<Arc<PgPool>>,
|
||||||
|
id: web::Path<Uuid>,
|
||||||
|
) -> TypedHttpResponse<Unit> {
|
||||||
|
services::read::get_unit_with_id(&db_conn, &id).await
|
||||||
|
}
|
||||||
|
|
||||||
#[get("/locations")]
|
#[get("/locations")]
|
||||||
pub async fn get_all_locations(
|
pub async fn get_all_locations(
|
||||||
db_conn: web::Data<Arc<PgPool>>,
|
db_conn: web::Data<Arc<PgPool>>,
|
||||||
|
@ -2,7 +2,7 @@ use std::collections::HashSet;
|
|||||||
|
|
||||||
use actix_web_utils::extensions::typed_response::TypedHttpResponse;
|
use actix_web_utils::extensions::typed_response::TypedHttpResponse;
|
||||||
use jl_types::{
|
use jl_types::{
|
||||||
domain::{agent::Agent, location::Location},
|
domain::{agent::Agent, location::Location, unit::Unit},
|
||||||
dto::{
|
dto::{
|
||||||
filters::Filter, listing::Listing, payloads::contact::ContactPayload,
|
filters::Filter, listing::Listing, payloads::contact::ContactPayload,
|
||||||
project_card::ProjectCardDto,
|
project_card::ProjectCardDto,
|
||||||
@ -37,6 +37,13 @@ pub async fn get_agent_with_id(
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_unit_with_id(conn: &PgPool, id: &Uuid) -> TypedHttpResponse<Unit> {
|
||||||
|
success!(unwrap_or_not_found!(
|
||||||
|
handle_db_read_op!(dao::unit::get_with_id(conn, id)),
|
||||||
|
"units"
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn get_all_locations(conn: &PgPool) -> TypedHttpResponse<HashSet<String>> {
|
pub async fn get_all_locations(conn: &PgPool) -> TypedHttpResponse<HashSet<String>> {
|
||||||
let locations: HashSet<String> = handle_db_read_op!(dao::location::fetch_all_locations(conn))
|
let locations: HashSet<String> = handle_db_read_op!(dao::location::fetch_all_locations(conn))
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
Loading…
Reference in New Issue
Block a user