fix(bug): not delete the correct and exsited data

This commit is contained in:
YuehuCao 2025-09-24 19:46:19 +08:00
parent bda5660bb6
commit bad6224bd9
2 changed files with 3 additions and 3 deletions

View File

@ -80,7 +80,7 @@ class PermissionHandler:
# Delete the old document with the original ID
try:
old_doc = await PermissionDoc.get(old_id)
if old_doc:
if (str(old_id) != custom_permission_id) and old_doc:
await old_doc.delete()
except Exception as e:
# Log the error but don't fail the operation

View File

@ -84,7 +84,7 @@ class RoleHandler:
# Delete the old document with the original ID
try:
old_doc = await RoleDoc.get(old_id)
if old_doc:
if (str(old_id) != custom_role_id) and old_doc:
await old_doc.delete()
except Exception as e:
# Log the error but don't fail the operation
@ -122,7 +122,7 @@ class RoleHandler:
raise RequestValidationError("role_id and permission_ids are required.")
doc = await RoleDoc.get(role_id)
if not doc:
raise RequestValidationError("Role not found.")
raise RequestValidationError(f"Role not found. {role_id}")
# Validate that all permission_ids exist in the permission collection
for permission_id in permission_ids: