2020-10-28 13:49:59 +00:00
|
|
|
use crate::schema::{gitea_tokens, users, tokens};
|
2020-10-28 01:07:25 +00:00
|
|
|
use chrono::NaiveDateTime;
|
2020-10-26 16:56:24 +00:00
|
|
|
use serde::Serialize;
|
|
|
|
use uuid::Uuid;
|
|
|
|
|
2020-10-28 01:07:25 +00:00
|
|
|
#[derive(Insertable)]
|
|
|
|
#[table_name = "users"]
|
|
|
|
pub struct NewUser {
|
|
|
|
pub email: String,
|
|
|
|
pub salutation: String,
|
|
|
|
pub is_admin: bool,
|
|
|
|
pub is_locked: bool,
|
|
|
|
pub tier: i32,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Queryable, Serialize, Debug, Clone)]
|
2020-10-26 16:56:24 +00:00
|
|
|
pub struct User {
|
2020-10-27 16:21:28 +00:00
|
|
|
pub id: Uuid,
|
|
|
|
pub email: String,
|
|
|
|
pub salutation: String,
|
|
|
|
pub is_admin: bool,
|
|
|
|
pub is_locked: bool,
|
|
|
|
pub tier: i32,
|
2020-10-28 01:07:25 +00:00
|
|
|
pub created_at: NaiveDateTime,
|
|
|
|
pub updated_at: NaiveDateTime,
|
2020-10-27 16:21:28 +00:00
|
|
|
}
|
|
|
|
|
2020-10-28 01:07:25 +00:00
|
|
|
#[derive(Insertable)]
|
2020-10-27 16:21:28 +00:00
|
|
|
#[table_name="gitea_tokens"]
|
2020-10-28 01:07:25 +00:00
|
|
|
pub struct NewGiteaToken {
|
|
|
|
pub user_id: Uuid,
|
|
|
|
pub access_token: String,
|
|
|
|
pub refresh_token: String,
|
|
|
|
}
|
|
|
|
|
2020-10-28 13:49:59 +00:00
|
|
|
#[derive(Queryable, Debug, Clone)]
|
2020-10-27 16:21:28 +00:00
|
|
|
pub struct GiteaToken {
|
|
|
|
pub id: Uuid,
|
|
|
|
pub user_id: Uuid,
|
|
|
|
pub access_token: String,
|
|
|
|
pub refresh_token: String,
|
2020-10-28 01:07:25 +00:00
|
|
|
pub created_at: NaiveDateTime,
|
|
|
|
pub updated_at: NaiveDateTime,
|
2020-10-26 16:56:24 +00:00
|
|
|
}
|
2020-10-28 13:49:59 +00:00
|
|
|
|
|
|
|
#[derive(Insertable)]
|
|
|
|
#[table_name="tokens"]
|
|
|
|
pub struct NewToken {
|
|
|
|
pub user_id: Uuid,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Queryable, Debug, Clone, Serialize)]
|
|
|
|
pub struct Token {
|
|
|
|
pub id: Uuid,
|
|
|
|
pub user_id: Uuid,
|
|
|
|
pub created_at: NaiveDateTime,
|
|
|
|
pub updated_at: NaiveDateTime,
|
|
|
|
pub deleted_at: Option<NaiveDateTime>,
|
|
|
|
}
|