#region 删除 /// <summary> /// 删除 /// </summary> /// <param name="inputViewModel">删除参数</param> /// <returns></returns> public ReturnedDataResult Delete(InputViewModel<int> inputViewModel) { if (inputViewModel == null) { return new ReturnedDataResult() { Status = ReturnedStatus.Error, Message = ResourceHelper.GetResourceValue("Common", "Common", "zh_cn", "DeleteFailByInputViewIsNull", "删除失败,失败原因:删除条件为空!") }; } var moduleList = _sysModuleRepository.GetList(); var idList = GetMenuIdList(inputViewModel.InputView, moduleList); idList.Add(inputViewModel.InputView); _sysModuleRepository.Delete(idList); return new ReturnedDataResult() { Data = new List<int> { inputViewModel.InputView }, Status = ReturnedStatus.Success, Message = ResourceHelper.GetResourceValue("Common", "Common", inputViewModel.Language, "DeleteSuccess", "删除成功!") }; } #endregion
#region 获取删除菜单的ID集合 /// <summary> /// 获取删除菜单的ID集合 /// </summary> /// <param name="parentId"></param> /// <param name="modules"></param> /// <returns></returns> private static List<int> GetMenuIdList(int parentId, List<Sys_Module> modules) { List<int> idlist = new List<int>(); var ids = modules.Where(s => s.ParentId == parentId).Select(s => s.Id).ToList(); foreach (var id in ids) { idlist.Add(id); List<int> childList = GetMenuIdList(id, modules); idlist.AddRange(childList); } return idlist; } #endregion