feat: user relation
This commit is contained in:
@@ -11,6 +11,7 @@ pub struct Env {
|
||||
pub smtp_name: String,
|
||||
pub smpt_host: String,
|
||||
pub redis_hostname: String,
|
||||
pub redis_port: u16,
|
||||
pub fe_url: String,
|
||||
pub rust_env: String,
|
||||
pub minio_endpoint: String,
|
||||
@@ -26,6 +27,10 @@ impl Env {
|
||||
.unwrap_or("3000".to_string())
|
||||
.parse()
|
||||
.unwrap_or(3000),
|
||||
redis_port: env::var("REDIS_PORT")
|
||||
.unwrap_or("5436".to_string())
|
||||
.parse()
|
||||
.unwrap_or(5436),
|
||||
access_token_secret: env::var("ACCESS_TOKEN_SECRET")
|
||||
.unwrap_or("default_access_secret".to_string()),
|
||||
refresh_token_secret: env::var("REFRESH_TOKEN_SECRET")
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum RedisKeyEnum {
|
||||
User,
|
||||
Token,
|
||||
Otp,
|
||||
}
|
||||
|
||||
impl fmt::Display for RedisKeyEnum {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
let str = match self {
|
||||
RedisKeyEnum::User => "user",
|
||||
RedisKeyEnum::Token => "token",
|
||||
RedisKeyEnum::Otp => "otp",
|
||||
};
|
||||
write!(f, "{}", str)
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,9 @@ use super::Env;
|
||||
use redis::Client;
|
||||
use redis::RedisResult;
|
||||
|
||||
pub mod key;
|
||||
pub use key::*;
|
||||
|
||||
pub async fn redisdb_init() -> RedisResult<Client> {
|
||||
let env = Env::new();
|
||||
let host_name = env.redis_hostname;
|
||||
|
||||
@@ -2,6 +2,7 @@ use std::fmt;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum ResourceEnum {
|
||||
Gacha,
|
||||
Users,
|
||||
Roles,
|
||||
Permissions,
|
||||
@@ -13,6 +14,7 @@ impl fmt::Display for ResourceEnum {
|
||||
ResourceEnum::Users => "app_users",
|
||||
ResourceEnum::Roles => "app_roles",
|
||||
ResourceEnum::Permissions => "app_permissions",
|
||||
ResourceEnum::Gacha => "app_gacha",
|
||||
};
|
||||
write!(f, "{}", str)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user