Rename ControllerUid to a more general EmgauwaUid (for macros)

This commit is contained in:
Tobias Reisinger 2024-04-28 02:29:34 +02:00
parent 07d3322c5a
commit 51aa0d3c99
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
11 changed files with 55 additions and 57 deletions
emgauwa-core/src/handlers/v1

View file

@ -3,7 +3,7 @@ use actix_web::{delete, get, put, web, HttpResponse};
use emgauwa_lib::db::DbController;
use emgauwa_lib::errors::{DatabaseError, EmgauwaError};
use emgauwa_lib::models::{convert_db_list, Controller, FromDbModel};
use emgauwa_lib::types::{ControllerUid, ControllerWsAction, RequestControllerUpdate};
use emgauwa_lib::types::{ControllerWsAction, EmgauwaUid, RequestControllerUpdate};
use sqlx::{Pool, Sqlite};
use crate::app_state;
@ -28,7 +28,7 @@ pub async fn show(
let mut pool_conn = pool.acquire().await?;
let (controller_uid,) = path.into_inner();
let uid = ControllerUid::try_from(controller_uid.as_str())?;
let uid = EmgauwaUid::try_from(controller_uid.as_str())?;
let controller = DbController::get_by_uid(&mut pool_conn, &uid)
.await?
@ -40,15 +40,15 @@ pub async fn show(
#[put("/controllers/{controller_id}")]
pub async fn update(
pool: web::Data<Pool<Sqlite>>,
app_state: web::Data<Addr<AppState>>,
path: web::Path<(String,)>,
data: web::Json<RequestControllerUpdate>,
pool: web::Data<Pool<Sqlite>>,
app_state: web::Data<Addr<AppState>>,
path: web::Path<(String,)>,
data: web::Json<RequestControllerUpdate>,
) -> Result<HttpResponse, EmgauwaError> {
let mut pool_conn = pool.acquire().await?;
let (controller_uid,) = path.into_inner();
let uid = ControllerUid::try_from(controller_uid.as_str())?;
let uid = EmgauwaUid::try_from(controller_uid.as_str())?;
let controller = DbController::get_by_uid(&mut pool_conn, &uid)
.await?
@ -79,7 +79,7 @@ pub async fn delete(
let mut pool_conn = pool.acquire().await?;
let (controller_uid,) = path.into_inner();
let uid = ControllerUid::try_from(controller_uid.as_str())?;
let uid = EmgauwaUid::try_from(controller_uid.as_str())?;
app_state
.send(app_state::DisconnectController {