/// <summary> /// 删除机构 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <JsonResponse> RemoveOrganization(EntityRequest input) { var existsChild = await _organizationAppService.GetAnyByParentIdAsync(input.Id); if (existsChild) { return(JsonResponse.Create(false, "该机构有下级机构")); } var exitsEmp = await _relationOrganizationEmployeeAppService.GetAnyByOrganizationIdAsync(input.Id); if (exitsEmp) { return(JsonResponse.Create(false, "该机构有下有成员")); } input.Ids = new List <string>() { input.Id }; var orgMenuIds = await _organizationMenuAppService.GetIdsByOrganizationIdsAsync(new List <string>() { input.Id }); var orgElementIds = await _organizationElementAppService.GetIdsByOrganizationIdsAsync(new List <string>() { input.Id }); var resJson = await _applicationEnginee.TryTransactionAsync(async() => { await _organizationAppService.RemoveAsync(input); await _organizationMenuAppService.RemoveAsync(new EntityRequest() { Ids = orgMenuIds, ModifyDate = DateTime.Now, ModifyUserId = input.ModifyUserId, ModifyUserName = input.ModifyUserName }); await _organizationElementAppService.RemoveAsync(new EntityRequest() { Ids = orgElementIds, ModifyDate = DateTime.Now, ModifyUserId = input.ModifyUserId, ModifyUserName = input.ModifyUserName }); }); return(resJson); }