Esempio n. 1
0
        public async Task <string> CreateOperation(CreateOperationInput input)
        {
            var operation = await _permissionRepository.FirstOrDefaultAsync(p => p.Code == input.Code);

            if (operation != null)
            {
                throw new BusinessException($"系统中已经存在Code为{input.Code}的操作");
            }
            foreach (var funcId in input.FunctionIds)
            {
                var funcInfo = await _functionRepository.SingleOrDefaultAsync(p => p.Id == funcId);

                if (funcInfo == null)
                {
                    throw new BusinessException($"系统中不存在{funcId}的功能");
                }
            }
            operation = new Permission()
            {
                Code = input.Code,
                Name = input.Name,
                Memo = input.Memo,
                Mold = PermissionMold.Operate,
            };
            await _functionManager.CreateOperation(operation, input.FunctionIds);

            return($"新增{input.Name}操作成功");
        }