From 9db120d7a0c73ad4ad167393d3b9a50ac1f50a27 Mon Sep 17 00:00:00 2001 From: Jim Hodapp Date: Sun, 12 Nov 2023 12:20:08 -0600 Subject: [PATCH] Tidy up with cargo fmt --- web/src/controller/organization_controller.rs | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/web/src/controller/organization_controller.rs b/web/src/controller/organization_controller.rs index 684caae..da4bdc4 100644 --- a/web/src/controller/organization_controller.rs +++ b/web/src/controller/organization_controller.rs @@ -4,10 +4,10 @@ use axum::response::IntoResponse; use axum::Json; use entity::organization; use entity::organization::Entity as Organization; -use sea_orm::ActiveValue::{Set, NotSet}; +use sea_orm::entity::EntityTrait; use sea_orm::ActiveModelTrait; +use sea_orm::ActiveValue::{NotSet, Set}; use sea_orm::DeleteResult; -use sea_orm::entity::EntityTrait; use serde_json::json; extern crate log; @@ -34,7 +34,10 @@ impl OrganizationController { /// --request POST \ /// --data '{"name":"My New Organization"}' \ /// http://localhost:3000/organizations - pub async fn create(State(app_state): State, Json(organization_json): Json) -> impl IntoResponse { + pub async fn create( + State(app_state): State, + Json(organization_json): Json, + ) -> impl IntoResponse { debug!("CREATE new Organization: {}", organization_json.name); let organization_active_model = organization::ActiveModel { @@ -42,7 +45,8 @@ impl OrganizationController { name: Set(organization_json.name), }; - let organization: organization::Model = organization_active_model.insert(&app_state.database_connection.unwrap()) + let organization: organization::Model = organization_active_model + .insert(&app_state.database_connection.unwrap()) .await .unwrap(); @@ -53,10 +57,14 @@ impl OrganizationController { /// Test this with curl: curl --header "Content-Type: application/json" \ in zsh at 12:03:06 /// --request DELETE \ /// http://localhost:3000/organizations/ - pub async fn delete(State(app_state): State, Path(id): Path) -> impl IntoResponse { + pub async fn delete( + State(app_state): State, + Path(id): Path, + ) -> impl IntoResponse { debug!("DELETE Organization by id: {}", id); - let res: DeleteResult = Organization::delete_by_id(id).exec(&app_state.database_connection.unwrap()) + let res: DeleteResult = Organization::delete_by_id(id) + .exec(&app_state.database_connection.unwrap()) .await .unwrap();