Rename UserDTO to UserDto
This commit is contained in:
parent
0fd1137361
commit
e1c4bb8fc7
@ -7,13 +7,13 @@ use bcrypt::{hash, verify, DEFAULT_COST};
|
||||
pub fn find_user_by_uid(
|
||||
uid: i32,
|
||||
conn: &SqliteConnection,
|
||||
) -> Result<Option<models::UserDTO>, errors::DomainError> {
|
||||
) -> Result<Option<models::UserDto>, errors::DomainError> {
|
||||
use crate::schema::users::dsl::*;
|
||||
|
||||
let maybe_user = users
|
||||
.select((name, created_at))
|
||||
.find(uid)
|
||||
.first::<models::UserDTO>(conn)
|
||||
.first::<models::UserDto>(conn)
|
||||
.optional();
|
||||
|
||||
Ok(maybe_user?)
|
||||
@ -22,9 +22,9 @@ pub fn find_user_by_uid(
|
||||
pub fn _find_user_by_name(
|
||||
user_name: String,
|
||||
conn: &SqliteConnection,
|
||||
) -> Result<Option<models::UserDTO>, errors::DomainError> {
|
||||
) -> Result<Option<models::UserDto>, errors::DomainError> {
|
||||
let maybe_user = query::_get_user_by_name(&user_name)
|
||||
.first::<models::UserDTO>(conn)
|
||||
.first::<models::UserDto>(conn)
|
||||
.optional();
|
||||
|
||||
Ok(maybe_user?)
|
||||
@ -32,11 +32,11 @@ pub fn _find_user_by_name(
|
||||
|
||||
pub fn get_all(
|
||||
conn: &SqliteConnection,
|
||||
) -> Result<Option<Vec<models::UserDTO>>, errors::DomainError> {
|
||||
) -> Result<Option<Vec<models::UserDto>>, errors::DomainError> {
|
||||
use crate::schema::users::dsl::*;
|
||||
Ok(users
|
||||
.select((name, created_at))
|
||||
.load::<models::UserDTO>(conn)
|
||||
.load::<models::UserDto>(conn)
|
||||
.optional()?)
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ pub fn get_all(
|
||||
pub fn insert_new_user(
|
||||
nu: models::NewUser,
|
||||
conn: &SqliteConnection,
|
||||
) -> Result<models::UserDTO, errors::DomainError> {
|
||||
) -> Result<models::UserDto, errors::DomainError> {
|
||||
// It is common when using Diesel with Actix web to import schema-related
|
||||
// modules inside a function's scope (rather than the normal module's scope)
|
||||
// to prevent import collisions and namespace pollution.
|
||||
@ -57,7 +57,7 @@ pub fn insert_new_user(
|
||||
|
||||
diesel::insert_into(users).values(&nu).execute(conn)?;
|
||||
let user =
|
||||
query::_get_user_by_name(&nu.name).first::<models::UserDTO>(conn)?;
|
||||
query::_get_user_by_name(&nu.name).first::<models::UserDto>(conn)?;
|
||||
Ok(user)
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ pub struct NewUser {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Queryable)]
|
||||
pub struct UserDTO {
|
||||
pub struct UserDto {
|
||||
pub name: String,
|
||||
pub registration_date: chrono::NaiveDateTime,
|
||||
}
|
||||
|
@ -4,20 +4,20 @@ pub trait UserService {
|
||||
fn find_user_by_uid(
|
||||
&self,
|
||||
uid: i32,
|
||||
) -> Result<Option<models::UserDTO>, errors::DomainError>;
|
||||
) -> Result<Option<models::UserDto>, errors::DomainError>;
|
||||
fn _find_user_by_name(
|
||||
&self,
|
||||
user_name: String,
|
||||
) -> Result<Option<models::UserDTO>, errors::DomainError>;
|
||||
) -> Result<Option<models::UserDto>, errors::DomainError>;
|
||||
|
||||
fn get_all(
|
||||
&self,
|
||||
) -> Result<Option<Vec<models::UserDTO>>, errors::DomainError>;
|
||||
) -> Result<Option<Vec<models::UserDto>>, errors::DomainError>;
|
||||
|
||||
fn insert_new_user(
|
||||
&self,
|
||||
nu: models::NewUser,
|
||||
) -> Result<models::UserDTO, errors::DomainError>;
|
||||
) -> Result<models::UserDto, errors::DomainError>;
|
||||
|
||||
// fn woot(&self) -> i32;
|
||||
|
||||
@ -37,7 +37,7 @@ impl UserService for UserServiceImpl {
|
||||
fn find_user_by_uid(
|
||||
&self,
|
||||
uid: i32,
|
||||
) -> Result<Option<models::UserDTO>, errors::DomainError> {
|
||||
) -> Result<Option<models::UserDto>, errors::DomainError> {
|
||||
let conn = self.pool.get()?;
|
||||
actions::find_user_by_uid(uid, &conn)
|
||||
}
|
||||
@ -45,14 +45,14 @@ impl UserService for UserServiceImpl {
|
||||
fn _find_user_by_name(
|
||||
&self,
|
||||
user_name: String,
|
||||
) -> Result<Option<models::UserDTO>, errors::DomainError> {
|
||||
) -> Result<Option<models::UserDto>, errors::DomainError> {
|
||||
let conn = self.pool.get()?;
|
||||
actions::_find_user_by_name(user_name, &conn)
|
||||
}
|
||||
|
||||
fn get_all(
|
||||
&self,
|
||||
) -> Result<Option<Vec<models::UserDTO>>, errors::DomainError> {
|
||||
) -> Result<Option<Vec<models::UserDto>>, errors::DomainError> {
|
||||
let conn = self.pool.get()?;
|
||||
actions::get_all(&conn)
|
||||
}
|
||||
@ -60,7 +60,7 @@ impl UserService for UserServiceImpl {
|
||||
fn insert_new_user(
|
||||
&self,
|
||||
nu: models::NewUser,
|
||||
) -> Result<models::UserDTO, errors::DomainError> {
|
||||
) -> Result<models::UserDto, errors::DomainError> {
|
||||
let conn = self.pool.get()?;
|
||||
actions::insert_new_user(nu, &conn)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user