From bc18bb647b96dd4423941187038709bd0fd2b968 Mon Sep 17 00:00:00 2001 From: Sphereso Date: Thu, 11 Jul 2024 21:28:28 +0200 Subject: [PATCH] backend: fix update endpoint (gyros) --- crates/backend/src/controller/license.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/crates/backend/src/controller/license.rs b/crates/backend/src/controller/license.rs index fa8fe3f..86cfdf0 100644 --- a/crates/backend/src/controller/license.rs +++ b/crates/backend/src/controller/license.rs @@ -68,14 +68,23 @@ impl LicenseController { pub async fn update_license( state: web::Data, - license: web::Json, + license: web::Json, path: Path, _executor: AuthedUser, ) -> actix_web::Result { let db = &state.db; - let mut license = license.into_inner(); + let license = license.into_inner(); let id = path.into_inner(); - license.id = ActiveValue::Unchanged(id); + let license = entity::license::ActiveModel { + id: ActiveValue::Unchanged(id), + amount: ActiveValue::Set(license.amount), + name: ActiveValue::Set(license.name), + start: ActiveValue::Set(license.start), + end: ActiveValue::Set(license.end), + key: ActiveValue::Set(license.key), + group_id: ActiveValue::Set(license.group_id), + note: ActiveValue::Set(license.note), + }; let res = license.update(db).await.map_err(ErrorInternalServerError)?; Ok(web::Json(res)) }