backend: fix update endpoint (gyros)

This commit is contained in:
Sphereso 2024-07-11 21:28:28 +02:00
parent 1c5c30be6e
commit bc18bb647b

View file

@ -68,14 +68,23 @@ impl LicenseController {
pub async fn update_license(
state: web::Data<AppState>,
license: web::Json<entity::license::ActiveModel>,
license: web::Json<entity::license::Model>,
path: Path<Uuid>,
_executor: AuthedUser,
) -> actix_web::Result<impl Responder> {
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))
}