Backend tests done. Everything looks great
This commit is contained in:
parent
2c3a752130
commit
5b86984645
@ -19,16 +19,24 @@ pub async fn start_all_routes(start_time: i64, db_conn: Arc<PgPool>) -> Result<(
|
||||
.app_data(client_state.clone())
|
||||
.app_data(web::Data::new(db_conn.clone()))
|
||||
.service(
|
||||
web::scope("/admin"), /*.service(super::admin::create_new_agent_profile)
|
||||
.service(super::admin::create_new_location)
|
||||
.service(super::admin::create_new_property)
|
||||
.service(super::admin::update_agent_info)
|
||||
.service(super::admin::update_listing))
|
||||
.service(web::scope("/read")
|
||||
.service(super::read::get_all_agents)
|
||||
.service(super::read::get_listing_container)
|
||||
.service(super::read::get_property_listings_paged)*/
|
||||
)
|
||||
web::scope("/admin")
|
||||
.service(super::admin::create_new_agent_profile)
|
||||
.service(super::admin::create_new_location)
|
||||
.service(super::admin::create_new_project)
|
||||
.service(super::admin::create_new_unit)
|
||||
.service(super::admin::update_agent)
|
||||
.service(super::admin::update_project)
|
||||
.service(super::admin::update_unit)
|
||||
.service(super::admin::delete_agent)
|
||||
.service(super::admin::delete_location)
|
||||
.service(super::admin::delete_project)
|
||||
.service(super::admin::delete_unit))
|
||||
.service(web::scope("/read")
|
||||
.service(super::read::get_all_agents)
|
||||
.service(super::read::get_all_locations)
|
||||
.service(super::read::get_locations_in_city)
|
||||
.service(super::read::get_projects_paged)
|
||||
.service(super::read::get_project_data))
|
||||
})
|
||||
.bind((HOST_ADDR, HOST_PORT))?
|
||||
.run();
|
||||
|
@ -51,7 +51,7 @@ pub async fn get_projects_paged(
|
||||
services::read::get_projects_paged(&db_conn, &page, &filters).await
|
||||
}
|
||||
|
||||
#[get("/projects/{project_id}")]
|
||||
#[get("/project/{project_id}")]
|
||||
pub async fn get_project_data(
|
||||
db_conn: web::Data<Arc<PgPool>>,
|
||||
project_id: Path<Uuid>,
|
||||
|
@ -138,34 +138,42 @@ pub async fn update_unit(
|
||||
pub async fn delete_project(conn: &PgPool, project_id: &Uuid) -> TypedHttpResponse<()> {
|
||||
let mut tx = handle_tx!(conn.begin());
|
||||
//let persisted_project = unwrap_or_not_found!(handle_db_read_op!(dao::project::get_with_id(conn, project_id)), "projects");
|
||||
// TODO: Test to see if this gives an error if no units are found
|
||||
handle_db_write_op!(dao::unit::delete_all_from_project(&mut tx, project_id), tx);
|
||||
// handle_db_write_op!(dao::location::delete_location(&mut tx, persisted_project.location_id));
|
||||
handle_db_write_op!(dao::project::delete(&mut tx, project_id), tx);
|
||||
let res = handle_db_write_op!(dao::project::delete(&mut tx, project_id), tx);
|
||||
if res.rows_affected() == 0 {
|
||||
return TypedHttpResponse::return_empty_response(404);
|
||||
}
|
||||
handle_tx!(tx.commit());
|
||||
success!(())
|
||||
}
|
||||
|
||||
pub async fn delete_location(conn: &PgPool, location_id: &Uuid) -> TypedHttpResponse<()> {
|
||||
let mut tx = handle_tx!(conn.begin());
|
||||
// TODO: Test to see if this gives an error if no locations are found
|
||||
handle_db_write_op!(dao::location::delete_location(&mut tx, location_id), tx);
|
||||
let res = handle_db_write_op!(dao::location::delete_location(&mut tx, location_id), tx);
|
||||
if res.rows_affected() == 0 {
|
||||
return TypedHttpResponse::return_empty_response(404);
|
||||
}
|
||||
handle_tx!(tx.commit());
|
||||
success!(())
|
||||
}
|
||||
|
||||
pub async fn delete_agent(conn: &PgPool, agent_id: &Uuid) -> TypedHttpResponse<()> {
|
||||
let mut tx = handle_tx!(conn.begin());
|
||||
// TODO: Test to see if this gives an error if no agents are found
|
||||
handle_db_write_op!(dao::agent::delete_agent(&mut tx, agent_id), tx);
|
||||
let res = handle_db_write_op!(dao::agent::delete_agent(&mut tx, agent_id), tx);
|
||||
if res.rows_affected() == 0 {
|
||||
return TypedHttpResponse::return_empty_response(404);
|
||||
}
|
||||
handle_tx!(tx.commit());
|
||||
success!(())
|
||||
}
|
||||
|
||||
pub async fn delete_unit(conn: &PgPool, unit_id: &Uuid) -> TypedHttpResponse<()> {
|
||||
let mut tx = handle_tx!(conn.begin());
|
||||
// TODO: Test to see if this gives an error if no units are found
|
||||
handle_db_write_op!(dao::unit::delete(&mut tx, unit_id), tx);
|
||||
let res = handle_db_write_op!(dao::unit::delete(&mut tx, unit_id), tx);
|
||||
if res.rows_affected() == 0 {
|
||||
return TypedHttpResponse::return_empty_response(404);
|
||||
}
|
||||
handle_tx!(tx.commit());
|
||||
success!(())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user