move cmd off of grpc

This commit is contained in:
2025-12-30 14:19:41 -05:00
parent 29f7f6d83b
commit 6980b7f6aa
26 changed files with 452 additions and 389 deletions

View File

@@ -4,6 +4,7 @@ use crate::panels::PanelService;
use actix_web::{delete, get, post, put, web, Responder};
use serde::Deserialize;
use std::sync::Arc;
use uuid::Uuid;
#[derive(Deserialize)]
struct CreateParam {
@@ -13,7 +14,7 @@ struct CreateParam {
#[derive(Deserialize)]
struct IdParam {
id: String,
id: Uuid,
}
#[post("/panel")]
@@ -22,7 +23,7 @@ pub(super) async fn new(
data: web::Json<CreateParam>,
) -> Result<impl Responder, HttpServerResultError> {
let uuid = panels.create(&data.name, &data.data).await?;
Ok(web::Json(uuid.value))
Ok(web::Json(uuid))
}
#[get("/panel")]
@@ -38,12 +39,10 @@ pub(super) async fn get_one(
panels: web::Data<Arc<PanelService>>,
path: web::Path<IdParam>,
) -> Result<impl Responder, HttpServerResultError> {
let result = panels.read(path.id.clone().into()).await?;
let result = panels.read(path.id).await?;
match result {
Some(result) => Ok(web::Json(result)),
None => Err(HttpServerResultError::PanelUuidNotFound {
uuid: path.id.clone(),
}),
None => Err(HttpServerResultError::PanelUuidNotFound { uuid: path.id }),
}
}
@@ -53,7 +52,7 @@ pub(super) async fn set(
path: web::Path<IdParam>,
data: web::Json<PanelUpdate>,
) -> Result<impl Responder, HttpServerResultError> {
panels.update(path.id.clone().into(), data.0).await?;
panels.update(path.id, data.0).await?;
Ok(web::Json(()))
}
@@ -62,6 +61,6 @@ pub(super) async fn delete(
panels: web::Data<Arc<PanelService>>,
path: web::Path<IdParam>,
) -> Result<impl Responder, HttpServerResultError> {
panels.delete(path.id.clone().into()).await?;
panels.delete(path.id).await?;
Ok(web::Json(()))
}