public async Task <AppSrvResult <long> > CreateAsync(DeptCreationDto input) { var isExists = (await GetAllFromCacheAsync()).Exists(x => x.FullName == input.FullName); if (isExists) { return(Problem(HttpStatusCode.BadRequest, "该部门全称已经存在")); } var dept = _mapper.Map <SysDept>(input); dept.Id = IdGenerater.GetNextId(); await this.SetDeptPids(dept); await _deptRepository.InsertAsync(dept); return(dept.Id); }
public async Task <ActionResult <long> > CreateAsync([FromBody] DeptCreationDto input) { return(CreatedResult(await _deptService.CreateAsync(input))); }