public async Task <CreateFunctionOutput> CreateFunction(CreateFunctionInput input) { input.CheckDataAnnotations().CheckValidResult(); var funcCode = input.WebApi.Replace("/", "."); //(input.WebApi.Replace("/", ".") + "." + input.Method).ToLower(); var existFunc = await _functionRepository.SingleOrDefaultAsync(p => p.Code == funcCode); if (existFunc != null) { throw new BusinessException($"系统中已经存在{input.WebApi}-{input.Method}的接口信息"); } if (input.ParentId != 0) { var parentFunc = await _functionRepository.SingleOrDefaultAsync(p => p.Id == input.ParentId); if (parentFunc == null) { throw new BusinessException($"系统中已经不存在id为{input.ParentId}的父功能信息"); } } var function = input.MapTo <Function>(); var funcId = await _functionRepository.InsertOrUpdateAndGetIdAsync(function); return(new CreateFunctionOutput() { FuncId = funcId, Tips = $"新增{input.WebApi}-{input.Method}的接口信息成功" }); }