refactor: Update permissions handling to filter out None values and ensure safe access

This commit is contained in:
MythEclipse
2025-09-26 01:08:18 +07:00
parent 1b7368a4b7
commit 17cc4ccdba
7 changed files with 17 additions and 16 deletions
@@ -27,8 +27,8 @@ pub struct PermissionsItemDto {
impl PermissionsItemDto {
pub fn from(dto: &PermissionsQueryDto) -> Self {
Self {
id: dto.id.id.to_raw(),
name: dto.name.clone(),
id: dto.id.as_ref().map(|id| id.id.to_raw()).unwrap_or_default(),
name: dto.name.clone().unwrap_or_default(),
created_at: dto.created_at.clone(),
updated_at: dto.updated_at.clone(),
}
@@ -37,8 +37,8 @@ impl PermissionsItemDto {
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct PermissionsQueryDto {
pub id: Thing,
pub name: String,
pub id: Option<Thing>,
pub name: Option<String>,
pub created_at: Option<String>,
pub updated_at: Option<String>,
}