feat: pagination
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
use lazy_static::lazy_static;
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use surrealdb::sql::Thing;
|
||||
use utoipa::ToSchema;
|
||||
use validator::Validate;
|
||||
|
||||
use crate::RolesItemDto;
|
||||
|
||||
lazy_static! {
|
||||
static ref PASSWORD_REGEX: Regex = Regex::new(r"^[A-Za-z\d@$!%*?&]{8,}$").unwrap();
|
||||
}
|
||||
@@ -82,6 +85,7 @@ pub struct UsersUpdateRequestDto {
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
|
||||
pub struct UsersItemDto {
|
||||
pub id: String,
|
||||
pub role: RolesItemDto,
|
||||
pub fullname: String,
|
||||
pub email: String,
|
||||
pub avatar: Option<String>,
|
||||
@@ -97,6 +101,54 @@ pub struct UsersItemDto {
|
||||
pub birthdate: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct UsersItemDtoRaw {
|
||||
pub id: Thing,
|
||||
pub role: Thing,
|
||||
pub fullname: String,
|
||||
pub email: String,
|
||||
pub avatar: Option<String>,
|
||||
pub phone_number: String,
|
||||
pub referred_by: Option<String>,
|
||||
pub referral_code: Option<String>,
|
||||
pub student_type: String,
|
||||
pub is_active: bool,
|
||||
pub is_profile_completed: bool,
|
||||
pub identity_number: Option<String>,
|
||||
pub religion: Option<String>,
|
||||
pub gender: Option<String>,
|
||||
pub birthdate: Option<String>,
|
||||
}
|
||||
|
||||
impl From<UsersItemDtoRaw> for UsersItemDto {
|
||||
fn from(raw: UsersItemDtoRaw) -> Self {
|
||||
Self {
|
||||
id: raw.id.id.to_string(),
|
||||
role: RolesItemDto {
|
||||
id: raw.role.id.to_string(),
|
||||
name: "".into(),
|
||||
is_deleted: false,
|
||||
permissions: vec![],
|
||||
created_at: None,
|
||||
updated_at: None,
|
||||
},
|
||||
fullname: raw.fullname,
|
||||
email: raw.email,
|
||||
avatar: raw.avatar,
|
||||
phone_number: raw.phone_number,
|
||||
referred_by: raw.referred_by,
|
||||
referral_code: raw.referral_code,
|
||||
student_type: raw.student_type,
|
||||
is_active: raw.is_active,
|
||||
is_profile_completed: raw.is_profile_completed,
|
||||
identity_number: raw.identity_number,
|
||||
religion: raw.religion,
|
||||
gender: raw.gender,
|
||||
birthdate: raw.birthdate,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
|
||||
pub struct UsersActiveInactiveRequestDto {
|
||||
pub is_active: bool,
|
||||
|
||||
Reference in New Issue
Block a user