Files
imphnen-backend-service/src/apps/v1/roles/roles_dto.rs
T

67 lines
1.8 KiB
Rust
Raw Normal View History

2025-03-30 02:46:16 +07:00
use crate::{PermissionsItemDto, PermissionsItemDtoRaw};
2025-03-23 20:42:38 +07:00
use serde::{Deserialize, Serialize};
2025-03-30 02:46:16 +07:00
use surrealdb::sql::Thing;
2025-03-23 20:42:38 +07:00
use utoipa::ToSchema;
2025-03-25 19:30:02 +07:00
use validator::Validate;
2025-03-23 20:42:38 +07:00
2025-03-25 19:30:02 +07:00
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema, Validate)]
2025-03-23 20:42:38 +07:00
pub struct RolesRequestUpdateDto {
2025-03-25 19:30:02 +07:00
#[validate(length(min = 1, message = "Role name must not be empty"))]
2025-03-23 20:42:38 +07:00
pub name: Option<String>,
pub permissions: Option<Vec<String>>,
}
2025-03-25 19:30:02 +07:00
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema, Validate)]
2025-03-23 20:42:38 +07:00
pub struct RolesRequestCreateDto {
2025-03-25 19:30:02 +07:00
#[validate(length(min = 1, message = "Role name must not be empty"))]
2025-03-23 20:42:38 +07:00
pub name: String,
pub permissions: Vec<String>,
}
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
pub struct RolesItemListDto {
pub id: String,
pub name: String,
pub created_at: Option<String>,
pub updated_at: Option<String>,
}
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
pub struct RolesItemDto {
2025-03-30 02:46:16 +07:00
pub id: String,
pub name: String,
pub permissions: Vec<PermissionsItemDto>,
pub created_at: Option<String>,
pub updated_at: Option<String>,
}
#[derive(Clone, Debug, Serialize, Deserialize, ToSchema)]
pub struct RolesItemByIdDto {
2025-03-23 20:42:38 +07:00
pub id: String,
pub name: String,
pub is_deleted: bool,
pub permissions: Vec<PermissionsItemDto>,
pub created_at: Option<String>,
pub updated_at: Option<String>,
}
2025-03-30 02:46:16 +07:00
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct RolesItemByIdDtoRaw {
pub id: Thing,
pub name: String,
pub permissions: Vec<PermissionsItemDtoRaw>,
pub is_deleted: bool,
pub created_at: Option<String>,
pub updated_at: Option<String>,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct RolesItemDtoRaw {
pub id: Thing,
pub name: String,
pub permissions: Vec<PermissionsItemDtoRaw>,
pub is_deleted: bool,
pub created_at: Option<String>,
pub updated_at: Option<String>,
}