Basic create user account
This commit is contained in:
34
geneit_backend/src/models.rs
Normal file
34
geneit_backend/src/models.rs
Normal file
@ -0,0 +1,34 @@
|
||||
use crate::schema::users;
|
||||
use diesel::prelude::*;
|
||||
|
||||
/// User ID holder
|
||||
#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize)]
|
||||
pub struct UserID(i32);
|
||||
|
||||
#[derive(Queryable, Debug)]
|
||||
pub struct User {
|
||||
id: i32,
|
||||
name: String,
|
||||
email: String,
|
||||
password: Option<String>,
|
||||
reset_password_token: Option<String>,
|
||||
time_create: i64,
|
||||
time_gen_reset_token: i64,
|
||||
time_activate: i64,
|
||||
active: bool,
|
||||
admin: bool,
|
||||
}
|
||||
|
||||
impl User {
|
||||
pub fn id(&self) -> UserID {
|
||||
UserID(self.id)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Insertable)]
|
||||
#[diesel(table_name = users)]
|
||||
pub struct NewUser<'a> {
|
||||
pub name: &'a str,
|
||||
pub email: &'a str,
|
||||
pub time_create: i64,
|
||||
}
|
Reference in New Issue
Block a user