Подключение к Postgres и тестовый эндпоинт авторизации

This commit is contained in:
2025-03-22 03:20:55 +04:00
parent 3cf42eea8a
commit 9f7460973e
24 changed files with 1091 additions and 47 deletions

26
src/database/models.rs Normal file
View File

@@ -0,0 +1,26 @@
use diesel::prelude::*;
use serde::Serialize;
#[derive(diesel_derive_enum::DbEnum, Serialize, Debug)]
#[ExistingTypePath = "crate::database::schema::sql_types::UserRole"]
#[DbValueStyle = "UPPERCASE"]
#[serde(rename_all = "UPPERCASE")]
pub enum UserRole {
Student,
Teacher,
Admin,
}
#[derive(Queryable, Selectable, Serialize)]
#[diesel(table_name = crate::database::schema::users)]
#[diesel(check_for_backend(diesel::pg::Pg))]
pub struct User {
pub id: String,
pub username: String,
pub password: String,
pub vk_id: Option<i32>,
pub access_token: String,
pub group: String,
pub role: UserRole,
pub version: String,
}