Can create a movement
This commit is contained in:
@ -5,6 +5,7 @@ use std::error::Error;
|
||||
pub mod accounts_controller;
|
||||
pub mod auth_controller;
|
||||
pub mod files_controller;
|
||||
pub mod movement_controller;
|
||||
pub mod server_controller;
|
||||
pub mod static_controller;
|
||||
pub mod tokens_controller;
|
||||
|
16
moneymgr_backend/src/controllers/movement_controller.rs
Normal file
16
moneymgr_backend/src/controllers/movement_controller.rs
Normal file
@ -0,0 +1,16 @@
|
||||
use crate::controllers::HttpResult;
|
||||
use crate::extractors::auth_extractor::AuthExtractor;
|
||||
use crate::services::movements_service;
|
||||
use crate::services::movements_service::UpdateMovementQuery;
|
||||
use actix_web::{HttpResponse, web};
|
||||
|
||||
/// Create a new movement
|
||||
pub async fn create(auth: AuthExtractor, req: web::Json<UpdateMovementQuery>) -> HttpResult {
|
||||
if let Some(err) = req.check_error(auth.user_id()).await? {
|
||||
return Ok(HttpResponse::BadRequest().json(err));
|
||||
}
|
||||
|
||||
movements_service::create(&req).await?;
|
||||
|
||||
Ok(HttpResponse::Created().finish())
|
||||
}
|
@ -41,6 +41,7 @@ pub struct ServerConstraints {
|
||||
pub token_ip_net: LenConstraints,
|
||||
pub token_max_inactivity: LenConstraints,
|
||||
pub account_name: LenConstraints,
|
||||
pub movement_label: LenConstraints,
|
||||
}
|
||||
|
||||
impl Default for ServerConstraints {
|
||||
@ -50,6 +51,7 @@ impl Default for ServerConstraints {
|
||||
token_ip_net: LenConstraints::max_only(44),
|
||||
token_max_inactivity: LenConstraints::new(3600, 3600 * 24 * 365),
|
||||
account_name: LenConstraints::not_empty(50),
|
||||
movement_label: LenConstraints::not_empty(200),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user