2020-05-09 06:37:08 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
|
|
use crate::schema::users;
|
|
|
|
use crate::utils::regexs;
|
|
|
|
use validator_derive::*;
|
|
|
|
|
2020-05-11 19:33:11 +00:00
|
|
|
#[derive(Debug, Clone, Queryable, Identifiable, Deserialize)]
|
2020-05-09 06:37:08 +00:00
|
|
|
pub struct User {
|
|
|
|
pub id: i32,
|
|
|
|
pub name: String,
|
|
|
|
pub password: String,
|
|
|
|
pub created_at: chrono::NaiveDateTime,
|
|
|
|
}
|
|
|
|
|
2020-05-11 19:33:11 +00:00
|
|
|
#[derive(Debug, Clone, Insertable, Deserialize, Validate)]
|
2020-05-09 06:37:08 +00:00
|
|
|
#[table_name = "users"]
|
|
|
|
pub struct NewUser {
|
|
|
|
#[validate(regex = "regexs::USERNAME_REG", length(min = 4, max = 10))]
|
|
|
|
pub name: String,
|
|
|
|
pub password: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, Queryable)]
|
|
|
|
pub struct UserDTO {
|
|
|
|
pub name: String,
|
|
|
|
pub registration_date: chrono::NaiveDateTime,
|
|
|
|
}
|