public async Task <IResultModel> Delete(Guid id) { var entity = await _menuRepository.GetAsync(id); if (entity == null) { return(ResultModel.Failed("该节点不存在")); } if (await _menuRepository.ExistsChild(id)) { return(ResultModel.Failed($"当前菜单({entity.Name})存在子菜单,请先删除子菜单")); } if (await _roleMenuRepository.ExistsWidthMenuId(id)) { return(ResultModel.Failed($"有角色绑定了当前菜单({entity.Name}),请先删除关联信息")); } _uow.BeginTransaction(); /* * 删除逻辑 * 1、删除菜单 * 2、删除该菜单与权限的关联信息 */ if (await _menuRepository.DeleteAsync(id) && await _menuPermissionRepository.DeleteByMenuId(id) && await _buttonRepository.DeleteByMenu(id) && await _roleMenuButtonRepository.DeleteByMenu(id)) { _uow.Commit(); await ClearAccountPermissionCache(id); return(ResultModel.Success()); } _uow.Rollback(); return(ResultModel.Failed()); }