Skip to content

Commit

Permalink
iam: unbind res_api (#581)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZzIsGod1019 authored Jan 9, 2024
1 parent c663278 commit 90d6cb5
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions support/iam/src/basic/serv/iam_res_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,21 +254,26 @@ impl RbumItemCrudOperation<iam_res::ActiveModel, IamResAddReq, IamResModifyReq,
}

async fn before_delete_item(id: &str, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<Option<IamResDetailResp>> {
Ok(Some(
Self::get_item(
id,
&IamResFilterReq {
basic: RbumBasicFilterReq {
with_sub_own_paths: true,
..Default::default()
},
let deleted_item = Self::get_item(
id,
&IamResFilterReq {
basic: RbumBasicFilterReq {
with_sub_own_paths: true,
..Default::default()
},
funs,
ctx,
)
.await?,
))
..Default::default()
},
funs,
ctx,
)
.await?;
if deleted_item.kind == IamResKind::Ele || deleted_item.kind == IamResKind::Menu {
let delete_api_res = IamResServ::find_to_simple_rel_roles(&IamRelKind::IamResApi, id, None, None, funs, ctx).await?.into_iter().map(|rel| rel.rel_id).collect_vec();
for delete_api_id in delete_api_res {
IamRelServ::delete_simple_rel(&IamRelKind::IamResApi, &delete_api_id, id, funs, ctx).await?;
}
}
Ok(Some(deleted_item))
}

async fn after_delete_item(_: &str, deleted_item: &Option<IamResDetailResp>, funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult<()> {
Expand Down

0 comments on commit 90d6cb5

Please sign in to comment.