Add delete endpoints and clean up filters

This commit is contained in:
2020-07-29 00:02:48 -04:00
parent 17cd3f12d2
commit 79b45551fd
7 changed files with 106 additions and 55 deletions

View File

@@ -36,6 +36,11 @@ pub async fn create_shop(shop: Shop, env: Environment) -> Result<impl Reply, Rej
Ok(reply)
}
pub async fn delete_shop(id: i32, env: Environment) -> Result<impl Reply, Rejection> {
Shop::delete(&env.db, id).await.map_err(reject_anyhow)?;
Ok(StatusCode::NO_CONTENT)
}
pub async fn get_owner(id: i32, env: Environment) -> Result<impl Reply, Rejection> {
let owner = Owner::get(&env.db, id).await.map_err(reject_anyhow)?;
let reply = json(&owner);
@@ -75,6 +80,11 @@ pub async fn create_owner(
Ok(reply)
}
pub async fn delete_owner(id: i32, env: Environment) -> Result<impl Reply, Rejection> {
Owner::delete(&env.db, id).await.map_err(reject_anyhow)?;
Ok(StatusCode::NO_CONTENT)
}
pub async fn get_interior_ref_list(id: i32, env: Environment) -> Result<impl Reply, Rejection> {
let interior_ref_list = InteriorRefList::get(&env.db, id)
.await
@@ -113,12 +123,9 @@ pub async fn create_interior_ref_list(
Ok(reply)
}
pub async fn bulk_create_interior_ref_lists(
interior_ref_lists: Vec<InteriorRefList>,
env: Environment,
) -> Result<impl Reply, Rejection> {
InteriorRefList::bulk_save(&env.db, interior_ref_lists)
pub async fn delete_interior_ref_list(id: i32, env: Environment) -> Result<impl Reply, Rejection> {
InteriorRefList::delete(&env.db, id)
.await
.map_err(reject_anyhow)?;
Ok(StatusCode::CREATED)
Ok(StatusCode::NO_CONTENT)
}