You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
886 B
37 lines
886 B
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::schema::users;
|
|
use crate::utils::regexs;
|
|
use validator::Validate;
|
|
use validator_derive::*;
|
|
use yarte::Template;
|
|
|
|
#[derive(Debug, Clone, Queryable, Identifiable, Deserialize)]
|
|
pub struct User {
|
|
pub id: i32,
|
|
pub name: String,
|
|
pub password: String,
|
|
pub created_at: chrono::NaiveDateTime,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Insertable, Deserialize, Validate)]
|
|
#[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,
|
|
}
|
|
|
|
#[derive(Template)]
|
|
#[template(path = "hello.hbs")]
|
|
pub struct CardTemplate<'a> {
|
|
pub title: &'a str,
|
|
pub body: String,
|
|
pub num: u32,
|
|
}
|