From 2db837fbee784a4b94250d17c2e797215786a7c2 Mon Sep 17 00:00:00 2001 From: Sphereso Date: Fri, 12 Jul 2024 10:47:29 +0200 Subject: [PATCH] =?UTF-8?q?backend:=20delete=20group=20endpoint=20(d=C3=B6?= =?UTF-8?q?nerteller=20protokol=20abgeschlossen)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/backend/src/controller/license.rs | 13 +++++++++++++ crates/backend/src/routes.rs | 1 + 2 files changed, 14 insertions(+) diff --git a/crates/backend/src/controller/license.rs b/crates/backend/src/controller/license.rs index 86cfdf0..f145110 100644 --- a/crates/backend/src/controller/license.rs +++ b/crates/backend/src/controller/license.rs @@ -101,4 +101,17 @@ impl LicenseController { .map_err(ErrorInternalServerError)?; Ok(HttpResponse::Ok().finish()) } + + pub async fn delete_group( + state: web::Data, + path: Path, + _executor: AuthedUser, + ) -> actix_web::Result { + let db = &state.db; + entity::license_group::Entity::delete_by_id(path.into_inner()) + .exec(db) + .await + .map_err(ErrorInternalServerError)?; + Ok(HttpResponse::Ok().finish()) + } } diff --git a/crates/backend/src/routes.rs b/crates/backend/src/routes.rs index 4eaf1a1..31dad61 100644 --- a/crates/backend/src/routes.rs +++ b/crates/backend/src/routes.rs @@ -26,6 +26,7 @@ pub fn config(cfg: &mut web::ServiceConfig) { .put(LicenseController::update_license), ) .route("/groups", web::post().to(LicenseController::create_group)) + .service(web::resource("/groups/{group_id}").delete(LicenseController::delete_group)) .service(web::scope("/auth").route("/login", web::post().to(AuthController::login))), ); }