From 0c342b34845e117fd89463dc327bdb67651170c6 Mon Sep 17 00:00:00 2001 From: Thani Sheun Date: Thu, 4 May 2023 17:03:49 +0200 Subject: [PATCH] group use statement, fix user sql --- migrations/20230501172218_user.sql | 2 +- src/error/api_error.rs | 4 +--- src/error/request_error.rs | 7 ++----- src/handler/auth_handler.rs | 10 +++------- src/handler/register_handler.rs | 6 ++---- src/middleware/auth.rs | 4 +--- 6 files changed, 10 insertions(+), 23 deletions(-) diff --git a/migrations/20230501172218_user.sql b/migrations/20230501172218_user.sql index 9f5d48a..19e4588 100644 --- a/migrations/20230501172218_user.sql +++ b/migrations/20230501172218_user.sql @@ -6,7 +6,7 @@ CREATE TABLE `user` ( `email` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, + `updated_at` timestamp NULL, `is_active` tinyint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), UNIQUE KEY `user_name` (`user_name`), diff --git a/src/error/api_error.rs b/src/error/api_error.rs index 1e73301..d984483 100644 --- a/src/error/api_error.rs +++ b/src/error/api_error.rs @@ -1,6 +1,4 @@ -use crate::error::db_error::DbError; -use crate::error::token_error::TokenError; -use crate::error::user_error::UserError; +use crate::error::{db_error::DbError,token_error::TokenError, user_error::UserError }; use axum::response::{IntoResponse, Response}; use thiserror::Error; diff --git a/src/error/request_error.rs b/src/error/request_error.rs index 8288b8e..58bb0f9 100644 --- a/src/error/request_error.rs +++ b/src/error/request_error.rs @@ -1,11 +1,8 @@ use crate::response::api_response::ApiErrorResponse; use async_trait::async_trait; -use axum::body::HttpBody; -use axum::extract::rejection::JsonRejection; -use axum::extract::FromRequest; -use axum::http::Request; +use axum::{body::HttpBody,http::Request, BoxError, Json}; +use axum::extract::{rejection::JsonRejection, FromRequest}; use axum::response::{IntoResponse, Response}; -use axum::{BoxError, Json}; use serde::de::DeserializeOwned; use thiserror::Error; use validator::Validate; diff --git a/src/handler/auth_handler.rs b/src/handler/auth_handler.rs index bc4b146..e8865fa 100644 --- a/src/handler/auth_handler.rs +++ b/src/handler/auth_handler.rs @@ -1,13 +1,9 @@ -use crate::dto::token_dto::TokenReadDto; -use crate::dto::user_dto::UserLoginDto; -use crate::error::api_error::ApiError; -use crate::error::request_error::ValidatedRequest; -use crate::error::user_error::UserError; +use crate::dto::{token_dto::TokenReadDto, user_dto::UserLoginDto}; +use crate::error::{api_error::ApiError,request_error::ValidatedRequest, user_error::UserError}; use crate::repository::user_repository::UserRepositoryTrait; use crate::service::token_service::TokenServiceTrait; use crate::state::auth_state::AuthState; -use axum::extract::State; -use axum::Json; +use axum::{extract::State, Json}; pub async fn auth( State(state): State, diff --git a/src/handler/register_handler.rs b/src/handler/register_handler.rs index 02be422..dc944fd 100644 --- a/src/handler/register_handler.rs +++ b/src/handler/register_handler.rs @@ -1,9 +1,7 @@ use crate::dto::user_dto::{UserReadDto, UserRegisterDto}; -use crate::error::api_error::ApiError; -use crate::error::request_error::ValidatedRequest; +use crate::error::{api_error::ApiError, request_error::ValidatedRequest}; use crate::state::user_state::UserState; -use axum::extract::State; -use axum::Json; +use axum::{extract::State, Json}; pub async fn register( State(state): State, diff --git a/src/middleware/auth.rs b/src/middleware/auth.rs index ca8cd07..66b555c 100644 --- a/src/middleware/auth.rs +++ b/src/middleware/auth.rs @@ -1,6 +1,4 @@ -use crate::error::api_error::ApiError; -use crate::error::token_error::TokenError; -use crate::error::user_error::UserError; +use crate::error::{api_error::ApiError, token_error::TokenError, user_error::UserError}; use crate::repository::user_repository::UserRepositoryTrait; use crate::service::token_service::TokenServiceTrait; use crate::state::token_state::TokenState;