mycommon-utils 0.1.1

common db or redis
Documentation
use std::collections::HashSet;
use serde::{Deserialize, Serialize};
use sea_orm::FromQueryResult;
use sea_orm::prelude::DateTime;
use crate::database::BigIntPrimaryKey;

#[derive(Clone,Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LoginUser {
    pub user_id: BigIntPrimaryKey,
    pub dept_id: BigIntPrimaryKey,
    pub store_id: BigIntPrimaryKey,
    pub personnel_number: Option<String>,
    pub user_name: String,
    pub nick_name: Option<String>,
    pub user_type: Option<String>,
    pub gender: Option<String>,
    pub phone_number: Option<String>,
    pub login_time: i64,
    pub expire_time: i64,
    pub token: String,
    pub is_admin: bool,
    pub is_super: bool,
    pub permissions: HashSet<String>,
    pub data_scope: DataScope,
    pub roles: Vec<String>,
    pub user: User,
    pub customer: Option<Customer>,
}
#[derive(Clone,Debug, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct Customer {
    pub store_id: BigIntPrimaryKey,
    pub name: String,
    pub second_name: Option<String>,
    pub third_name: Option<String>,
    pub suffix: String,
}
#[derive(Clone,Debug, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct User{
    pub id: BigIntPrimaryKey,
    pub dept_id: BigIntPrimaryKey,
    pub dept_name: Option<String>,
    pub store_id: BigIntPrimaryKey,
    pub personnel_number: Option<String>,
    pub user_name: String,
    pub nick_name: Option<String>,
    pub user_type: Option<String>,
    pub gender: Option<String>,
    pub date_of_birth: Option<String>,
    pub email: Option<String>,
    pub phone_number: Option<String>,
    pub avatar: Option<String>,
    pub status: i8,
    pub first_name: Option<String>,
    pub last_name: Option<String>,
    pub dept: Option<SysDeptResponse>,
    pub post_ids: Vec<BigIntPrimaryKey>,
    pub roles: Vec<SysRoleResponse>,

}

#[derive(Clone,Debug, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct DataScope {
    pub dept_ids: Vec<BigIntPrimaryKey>,
    pub is_self_only: bool,
}

#[derive(Debug, Serialize, Deserialize,FromQueryResult,Clone)]
#[serde(rename_all = "camelCase")]
pub struct SysRoleResponse {
    pub role_id: BigIntPrimaryKey,
    pub role_name: String,
    pub role_key: String,
    pub data_scope: String,
    pub role_sort: i32,
    pub menu_check_strictly: Option<i8>,
    pub dept_check_strictly: Option<i8>,
    pub status: i8,
    pub remark: Option<String>,
    pub create_time: DateTime,
    pub update_time: Option<DateTime>,
}
#[derive(Clone, Debug, Serialize, Deserialize, FromQueryResult, Default)]
#[serde(rename_all = "camelCase")]
pub struct SysDeptResponse {
    pub id: BigIntPrimaryKey,
    pub parent_id: BigIntPrimaryKey,
    pub ancestors: String,
    pub dept_name: String,
    pub order_num: Option<i64>,
    pub leader: Option<String>,
    pub phone: Option<String>,
    pub email: Option<String>,
    pub status: i8,
    pub del_flag: Option<String>,
}