Rename request models
This commit is contained in:
parent
ccc30dcdaf
commit
e2f3d7b82a
5 changed files with 19 additions and 19 deletions
|
@ -3,7 +3,7 @@ use actix_web::{delete, get, put, web, HttpResponse};
|
||||||
use emgauwa_lib::db::DbController;
|
use emgauwa_lib::db::DbController;
|
||||||
use emgauwa_lib::errors::{DatabaseError, EmgauwaError};
|
use emgauwa_lib::errors::{DatabaseError, EmgauwaError};
|
||||||
use emgauwa_lib::models::{convert_db_list, Controller, FromDbModel};
|
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 sqlx::{Pool, Sqlite};
|
||||||
|
|
||||||
use crate::app_state;
|
use crate::app_state;
|
||||||
|
@ -43,7 +43,7 @@ pub async fn update(
|
||||||
pool: web::Data<Pool<Sqlite>>,
|
pool: web::Data<Pool<Sqlite>>,
|
||||||
app_state: web::Data<Addr<AppState>>,
|
app_state: web::Data<Addr<AppState>>,
|
||||||
path: web::Path<(String,)>,
|
path: web::Path<(String,)>,
|
||||||
data: web::Json<RequestUpdateController>,
|
data: web::Json<RequestControllerUpdate>,
|
||||||
) -> Result<HttpResponse, EmgauwaError> {
|
) -> Result<HttpResponse, EmgauwaError> {
|
||||||
let mut pool_conn = pool.acquire().await?;
|
let mut pool_conn = pool.acquire().await?;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use actix_web::{get, put, web, HttpResponse};
|
||||||
use emgauwa_lib::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbTag};
|
use emgauwa_lib::db::{DbController, DbJunctionRelaySchedule, DbRelay, DbTag};
|
||||||
use emgauwa_lib::errors::{DatabaseError, EmgauwaError};
|
use emgauwa_lib::errors::{DatabaseError, EmgauwaError};
|
||||||
use emgauwa_lib::models::{convert_db_list, FromDbModel, Relay};
|
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 emgauwa_lib::utils;
|
||||||
use sqlx::{Pool, Sqlite};
|
use sqlx::{Pool, Sqlite};
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ pub async fn update_for_controller(
|
||||||
pool: web::Data<Pool<Sqlite>>,
|
pool: web::Data<Pool<Sqlite>>,
|
||||||
app_state: web::Data<Addr<AppState>>,
|
app_state: web::Data<Addr<AppState>>,
|
||||||
path: web::Path<(String, i64)>,
|
path: web::Path<(String, i64)>,
|
||||||
data: web::Json<RequestUpdateRelay>,
|
data: web::Json<RequestRelayUpdate>,
|
||||||
) -> Result<HttpResponse, EmgauwaError> {
|
) -> Result<HttpResponse, EmgauwaError> {
|
||||||
let mut pool_conn = pool.acquire().await?;
|
let mut pool_conn = pool.acquire().await?;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ use emgauwa_lib::db::{DbController, DbJunctionRelaySchedule, DbSchedule, DbTag};
|
||||||
use emgauwa_lib::errors::{ApiError, DatabaseError, EmgauwaError};
|
use emgauwa_lib::errors::{ApiError, DatabaseError, EmgauwaError};
|
||||||
use emgauwa_lib::models::{convert_db_list, FromDbModel, Schedule};
|
use emgauwa_lib::models::{convert_db_list, FromDbModel, Schedule};
|
||||||
use emgauwa_lib::types::{
|
use emgauwa_lib::types::{
|
||||||
ControllerWsAction, RequestCreateSchedule, RequestUpdateSchedule, ScheduleUid,
|
ControllerWsAction, RequestScheduleCreate, RequestScheduleUpdate, ScheduleUid,
|
||||||
};
|
};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use sqlx::pool::PoolConnection;
|
use sqlx::pool::PoolConnection;
|
||||||
|
@ -62,7 +62,7 @@ pub async fn show(
|
||||||
#[post("/schedules")]
|
#[post("/schedules")]
|
||||||
pub async fn add(
|
pub async fn add(
|
||||||
pool: web::Data<Pool<Sqlite>>,
|
pool: web::Data<Pool<Sqlite>>,
|
||||||
data: web::Json<RequestCreateSchedule>,
|
data: web::Json<RequestScheduleCreate>,
|
||||||
) -> Result<HttpResponse, EmgauwaError> {
|
) -> Result<HttpResponse, EmgauwaError> {
|
||||||
let mut pool_conn = pool.acquire().await?;
|
let mut pool_conn = pool.acquire().await?;
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ pub async fn add(
|
||||||
|
|
||||||
async fn add_list_single(
|
async fn add_list_single(
|
||||||
conn: &mut PoolConnection<Sqlite>,
|
conn: &mut PoolConnection<Sqlite>,
|
||||||
request_schedule: &RequestCreateSchedule,
|
request_schedule: &RequestScheduleCreate,
|
||||||
) -> Result<DbSchedule, DatabaseError> {
|
) -> Result<DbSchedule, DatabaseError> {
|
||||||
let new_schedule = DbSchedule::create(
|
let new_schedule = DbSchedule::create(
|
||||||
conn,
|
conn,
|
||||||
|
@ -106,7 +106,7 @@ async fn add_list_single(
|
||||||
#[post("/schedules/list")]
|
#[post("/schedules/list")]
|
||||||
pub async fn add_list(
|
pub async fn add_list(
|
||||||
pool: web::Data<Pool<Sqlite>>,
|
pool: web::Data<Pool<Sqlite>>,
|
||||||
data: web::Json<Vec<RequestCreateSchedule>>,
|
data: web::Json<Vec<RequestScheduleCreate>>,
|
||||||
) -> Result<HttpResponse, EmgauwaError> {
|
) -> Result<HttpResponse, EmgauwaError> {
|
||||||
let mut pool_conn = pool.acquire().await?;
|
let mut pool_conn = pool.acquire().await?;
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ pub async fn update(
|
||||||
pool: web::Data<Pool<Sqlite>>,
|
pool: web::Data<Pool<Sqlite>>,
|
||||||
app_state: web::Data<Addr<AppState>>,
|
app_state: web::Data<Addr<AppState>>,
|
||||||
path: web::Path<(String,)>,
|
path: web::Path<(String,)>,
|
||||||
data: web::Json<RequestUpdateSchedule>,
|
data: web::Json<RequestScheduleUpdate>,
|
||||||
) -> Result<HttpResponse, EmgauwaError> {
|
) -> Result<HttpResponse, EmgauwaError> {
|
||||||
let mut pool_conn = pool.acquire().await?;
|
let mut pool_conn = pool.acquire().await?;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use actix_web::{delete, get, post, web, HttpResponse};
|
||||||
use emgauwa_lib::db::DbTag;
|
use emgauwa_lib::db::DbTag;
|
||||||
use emgauwa_lib::errors::{DatabaseError, EmgauwaError};
|
use emgauwa_lib::errors::{DatabaseError, EmgauwaError};
|
||||||
use emgauwa_lib::models::{FromDbModel, Tag};
|
use emgauwa_lib::models::{FromDbModel, Tag};
|
||||||
use emgauwa_lib::types::RequestCreateTag;
|
use emgauwa_lib::types::RequestTagCreate;
|
||||||
use sqlx::{Pool, Sqlite};
|
use sqlx::{Pool, Sqlite};
|
||||||
|
|
||||||
#[get("/tags")]
|
#[get("/tags")]
|
||||||
|
@ -49,7 +49,7 @@ pub async fn delete(
|
||||||
#[post("/tags")]
|
#[post("/tags")]
|
||||||
pub async fn add(
|
pub async fn add(
|
||||||
pool: web::Data<Pool<Sqlite>>,
|
pool: web::Data<Pool<Sqlite>>,
|
||||||
data: web::Json<RequestCreateTag>,
|
data: web::Json<RequestTagCreate>,
|
||||||
) -> Result<HttpResponse, EmgauwaError> {
|
) -> Result<HttpResponse, EmgauwaError> {
|
||||||
let mut pool_conn = pool.acquire().await?;
|
let mut pool_conn = pool.acquire().await?;
|
||||||
|
|
||||||
|
|
|
@ -7,21 +7,21 @@ use crate::errors::DatabaseError;
|
||||||
use crate::types::ScheduleUid;
|
use crate::types::ScheduleUid;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct RequestCreateSchedule {
|
pub struct RequestScheduleCreate {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub periods: DbPeriods,
|
pub periods: DbPeriods,
|
||||||
pub tags: Option<Vec<String>>,
|
pub tags: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct RequestUpdateSchedule {
|
pub struct RequestScheduleUpdate {
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
pub periods: Option<DbPeriods>,
|
pub periods: Option<DbPeriods>,
|
||||||
pub tags: Option<Vec<String>>,
|
pub tags: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct RequestUpdateRelay {
|
pub struct RequestRelayUpdate {
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
pub active_schedule: Option<RequestScheduleId>,
|
pub active_schedule: Option<RequestScheduleId>,
|
||||||
pub schedules: Option<Vec<RequestScheduleId>>,
|
pub schedules: Option<Vec<RequestScheduleId>>,
|
||||||
|
@ -34,12 +34,12 @@ pub struct RequestScheduleId {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct RequestUpdateController {
|
pub struct RequestControllerUpdate {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct RequestCreateTag {
|
pub struct RequestTagCreate {
|
||||||
pub tag: String,
|
pub tag: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue