From e2f3d7b82a145b09ae0e5b9526ffa655b0b18318 Mon Sep 17 00:00:00 2001 From: Tobias Reisinger Date: Fri, 26 Apr 2024 02:14:47 +0200 Subject: [PATCH] Rename request models --- emgauwa-core/src/handlers/v1/controllers.rs | 10 +++++----- emgauwa-core/src/handlers/v1/relays.rs | 4 ++-- emgauwa-core/src/handlers/v1/schedules.rs | 10 +++++----- emgauwa-core/src/handlers/v1/tags.rs | 4 ++-- emgauwa-lib/src/types/request.rs | 10 +++++----- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/emgauwa-core/src/handlers/v1/controllers.rs b/emgauwa-core/src/handlers/v1/controllers.rs index eb1b870..24404fa 100644 --- a/emgauwa-core/src/handlers/v1/controllers.rs +++ b/emgauwa-core/src/handlers/v1/controllers.rs @@ -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, RequestUpdateController}; +use emgauwa_lib::types::{ControllerUid, ControllerWsAction, RequestControllerUpdate}; use sqlx::{Pool, Sqlite}; use crate::app_state; @@ -40,10 +40,10 @@ pub async fn show( #[put("/controllers/{controller_id}")] pub async fn update( - pool: web::Data>, - app_state: web::Data>, - path: web::Path<(String,)>, - data: web::Json, + pool: web::Data>, + app_state: web::Data>, + path: web::Path<(String,)>, + data: web::Json, ) -> Result { let mut pool_conn = pool.acquire().await?; diff --git a/emgauwa-core/src/handlers/v1/relays.rs b/emgauwa-core/src/handlers/v1/relays.rs index 2d519d4..93b0db3 100644 --- a/emgauwa-core/src/handlers/v1/relays.rs +++ b/emgauwa-core/src/handlers/v1/relays.rs @@ -3,7 +3,7 @@ use actix_web::{get, put, web, HttpResponse}; use emgauwa_lib::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbTag}; use emgauwa_lib::errors::{DatabaseError, EmgauwaError}; use emgauwa_lib::models::{convert_db_list, FromDbModel, Relay}; -use emgauwa_lib::types::{ControllerUid, ControllerWsAction, RequestUpdateRelay}; +use emgauwa_lib::types::{ControllerUid, ControllerWsAction, RequestRelayUpdate}; use emgauwa_lib::utils; use sqlx::{Pool, Sqlite}; @@ -86,7 +86,7 @@ pub async fn update_for_controller( pool: web::Data>, app_state: web::Data>, path: web::Path<(String, i64)>, - data: web::Json, + data: web::Json, ) -> Result { let mut pool_conn = pool.acquire().await?; diff --git a/emgauwa-core/src/handlers/v1/schedules.rs b/emgauwa-core/src/handlers/v1/schedules.rs index 21bef5a..3018d3c 100644 --- a/emgauwa-core/src/handlers/v1/schedules.rs +++ b/emgauwa-core/src/handlers/v1/schedules.rs @@ -4,7 +4,7 @@ use emgauwa_lib::db::{DbController, DbJunctionRelaySchedule, DbSchedule, DbTag}; use emgauwa_lib::errors::{ApiError, DatabaseError, EmgauwaError}; use emgauwa_lib::models::{convert_db_list, FromDbModel, Schedule}; use emgauwa_lib::types::{ - ControllerWsAction, RequestCreateSchedule, RequestUpdateSchedule, ScheduleUid, + ControllerWsAction, RequestScheduleCreate, RequestScheduleUpdate, ScheduleUid, }; use itertools::Itertools; use sqlx::pool::PoolConnection; @@ -62,7 +62,7 @@ pub async fn show( #[post("/schedules")] pub async fn add( pool: web::Data>, - data: web::Json, + data: web::Json, ) -> Result { let mut pool_conn = pool.acquire().await?; @@ -86,7 +86,7 @@ pub async fn add( async fn add_list_single( conn: &mut PoolConnection, - request_schedule: &RequestCreateSchedule, + request_schedule: &RequestScheduleCreate, ) -> Result { let new_schedule = DbSchedule::create( conn, @@ -106,7 +106,7 @@ async fn add_list_single( #[post("/schedules/list")] pub async fn add_list( pool: web::Data>, - data: web::Json>, + data: web::Json>, ) -> Result { let mut pool_conn = pool.acquire().await?; @@ -125,7 +125,7 @@ pub async fn update( pool: web::Data>, app_state: web::Data>, path: web::Path<(String,)>, - data: web::Json, + data: web::Json, ) -> Result { let mut pool_conn = pool.acquire().await?; diff --git a/emgauwa-core/src/handlers/v1/tags.rs b/emgauwa-core/src/handlers/v1/tags.rs index 5a42715..a34e29a 100644 --- a/emgauwa-core/src/handlers/v1/tags.rs +++ b/emgauwa-core/src/handlers/v1/tags.rs @@ -2,7 +2,7 @@ use actix_web::{delete, get, post, web, HttpResponse}; use emgauwa_lib::db::DbTag; use emgauwa_lib::errors::{DatabaseError, EmgauwaError}; use emgauwa_lib::models::{FromDbModel, Tag}; -use emgauwa_lib::types::RequestCreateTag; +use emgauwa_lib::types::RequestTagCreate; use sqlx::{Pool, Sqlite}; #[get("/tags")] @@ -49,7 +49,7 @@ pub async fn delete( #[post("/tags")] pub async fn add( pool: web::Data>, - data: web::Json, + data: web::Json, ) -> Result { let mut pool_conn = pool.acquire().await?; diff --git a/emgauwa-lib/src/types/request.rs b/emgauwa-lib/src/types/request.rs index 036cf9d..c4d20e7 100644 --- a/emgauwa-lib/src/types/request.rs +++ b/emgauwa-lib/src/types/request.rs @@ -7,21 +7,21 @@ use crate::errors::DatabaseError; use crate::types::ScheduleUid; #[derive(Debug, Serialize, Deserialize)] -pub struct RequestCreateSchedule { +pub struct RequestScheduleCreate { pub name: String, pub periods: DbPeriods, pub tags: Option>, } #[derive(Debug, Serialize, Deserialize)] -pub struct RequestUpdateSchedule { +pub struct RequestScheduleUpdate { pub name: Option, pub periods: Option, pub tags: Option>, } #[derive(Debug, Serialize, Deserialize)] -pub struct RequestUpdateRelay { +pub struct RequestRelayUpdate { pub name: Option, pub active_schedule: Option, pub schedules: Option>, @@ -34,12 +34,12 @@ pub struct RequestScheduleId { } #[derive(Debug, Serialize, Deserialize)] -pub struct RequestUpdateController { +pub struct RequestControllerUpdate { pub name: String, } #[derive(Debug, Serialize, Deserialize)] -pub struct RequestCreateTag { +pub struct RequestTagCreate { pub tag: String, }