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