GetAddOrRemoveOrganizationElementRequest(OrganizationElementRequestDto organizationElementRequestDto) { //查询该机构所有模块元素 var allExitsEelments = await _organizationElementAppService.GetElementByOrganizationIdsAsync(new List <string> { organizationElementRequestDto.OrganizationId }); var allExitsElementIds = allExitsEelments.Select(m => m.ElementId).ToList(); var addMenuIds = organizationElementRequestDto.ElementIds.Except(allExitsElementIds); var delMenuIds = allExitsElementIds.Except(organizationElementRequestDto.ElementIds); var addDto = addMenuIds.Select(m => new OrganizationElementRequestDto { Id = Guid.NewGuid().ToString(), ElementId = m, OrganizationId = organizationElementRequestDto.OrganizationId, CreateUserId = organizationElementRequestDto.CreateUserId, CreateUserName = organizationElementRequestDto.CreateUserName, }); var delDto = delMenuIds.Select(m => new OrganizationElementRequestDto { ElementId = m, OrganizationId = organizationElementRequestDto.OrganizationId, IsDelete = true, ModifyUserId = organizationElementRequestDto.ModifyUserId, ModifyUserName = organizationElementRequestDto.ModifyUserName, ModifyDate = DateTime.Now }); return(addDto.ToList(), delDto.ToList()); }
/// <summary> /// 新增 /// </summary> /// <param name="organizationElementRequestDto"></param> /// <returns></returns> public async Task <bool> CreateAsync(OrganizationElementRequestDto organizationElementRequestDto) { var organizationElement = organizationElementRequestDto.MapToCreateEntity <OrganizationElementRequestDto, OrganizationElement>(); await OrganizationElementValidatorsFilter.DoValidationAsync(_organizationElementRespository, organizationElement, ValidatorTypeConstants.Create); return(await _organizationElementRespository.InsertAsync(organizationElement)); }
/// <summary> /// 修改 /// </summary> /// <param name="organizationElementRequestDto"></param> /// <returns></returns> public async Task <bool> ModifyAsync(OrganizationElementRequestDto organizationElementRequestDto) { var organizationElement = await _organizationElementRespository.FirstOrDefaultAsync(e => e.Id == organizationElementRequestDto.Id); var entity = organizationElementRequestDto.MapToModifyEntity <OrganizationElementRequestDto, OrganizationElement>(organizationElement); await OrganizationElementValidatorsFilter.DoValidationAsync(_organizationElementRespository, entity, ValidatorTypeConstants.Modify); return(await _organizationElementRespository.UpdateAsync(entity)); }
/// <summary> /// 修改 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <JsonResponse> Modify(OrganizationElementRequestDto input) { input.InitModifyRequest(); var resJson = await _applicationEnginee.TryTransactionAsync(async() => { await _organizationElementAppService.ModifyAsync(input); }); return(resJson); }
/// <summary> /// 保存机构模块元素 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <JsonResponse> SaveOrganizationModuleElement(OrganizationElementRequestDto input) { var result = await GetAddOrRemoveOrganizationElementRequest(input); var resJson = await _applicationEnginee.TryTransactionAsync(async() => { await _organizationElementAppService.BatchCreateAsync(result.Item1); await _organizationElementAppService.BatchRemoveAsync(result.Item2); }); return(resJson); }
/// <summary> /// 获取机构模块元素信息 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <IList <PowerSelectViewResponse> > GetOrganizationModuleElement(OrganizationElementRequestDto input) { var orgElementDtos = await _organizationElementAppService.GetElementByOrganizationIdsAsync(new List <string> { input.OrganizationId }); return(orgElementDtos.Select(o => new PowerSelectViewResponse { Id = o.ElementId }).ToList()); }
/// <summary> /// 获取机构模块元素信息 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <IList <PowerSelectViewResponse> > GetOrganizationModuleElement(OrganizationElementRequestDto input) { return(await _moduleElementDomainService.GetOrganizationModuleElement(input)); }
/// <summary> /// 保存机构模块元素 /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <JsonResponse> SaveOrganizationModuleElement(OrganizationElementRequestDto input) { input.InitCreateRequest(); input.InitModifyRequest(); return(await _moduleElementDomainService.SaveOrganizationModuleElement(input)); }