You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/oab/src/models/app.rs

89 lines
1.8 KiB
Rust

//
// app.rs
// Copyright (C) 2022 veypi <i@veypi.com>
// 2022-07-09 00:18
// Distributed under terms of the Apache license.
//
3 years ago
use chrono::NaiveDateTime;
3 years ago
use serde::{Deserialize, Serialize};
3 years ago
#[derive(Debug, Serialize, Deserialize, Clone, sqlx::Type)]
#[repr(i64)]
3 years ago
pub enum AppJoin {
3 years ago
Auto = 0,
Disabled = 1,
Applying = 2,
3 years ago
}
3 years ago
#[derive(Debug, Serialize, Deserialize, sqlx::FromRow)]
pub struct App {
pub id: String,
3 years ago
pub created: Option<NaiveDateTime>,
pub updated: Option<NaiveDateTime>,
pub delete_flag: bool,
pub name: Option<String>,
pub des: Option<String>,
pub icon: Option<String>,
3 years ago
pub user_count: i64,
pub hide: bool,
3 years ago
pub join_method: AppJoin,
pub role_id: Option<String>,
pub redirect: Option<String>,
3 years ago
pub status: i64,
}
impl App {
pub fn new() -> Self {
Self {
3 years ago
id: "".to_string(),
created: None,
updated: None,
delete_flag: false,
name: None,
des: None,
icon: None,
user_count: 0,
hide: false,
3 years ago
join_method: AppJoin::Auto,
role_id: None,
redirect: None,
status: 0,
}
}
}
3 years ago
#[derive(Debug, Deserialize, Serialize, Clone, sqlx::Type)]
#[repr(i64)]
pub enum AUStatus {
3 years ago
OK = 0,
Disabled = 1,
Applying = 2,
Deny = 3,
}
3 years ago
#[derive(Debug, Serialize, Deserialize, sqlx::FromRow)]
pub struct AppUser {
3 years ago
pub created: Option<NaiveDateTime>,
pub updated: Option<NaiveDateTime>,
pub app_id: String,
pub user_id: String,
pub status: AUStatus,
}
impl AppUser {
pub fn new() -> Self {
Self {
created: None,
updated: None,
app_id: "".to_string(),
user_id: "".to_string(),
status: AUStatus::OK,
}
}
}