Example #1
0
        public async Task <Result> ModifyAction([FromBody] PermissionActionModifyRequestDto dto)
        {
            //验证请求数据合法性
            var result = dto.Valid();

            if (!result.Success)
            {
                return(result);
            }

            //修改功能权限
            var modifyResult = await this._serviceProvider.GetRequiredService <PermissionChangeService>()
                               .ModifyAction(dto.Id, dto.Name, dto.Description, dto.Enable, dto.ApiTemplate, dto.IsLogger, dto.Sort);

            if (!modifyResult.Success)
            {
                return(modifyResult);
            }

            //数据持久化
            _operateLog.Record(ASFPermissions.PermissionModifyAction, dto, "Success");  //记录日志
            await _permissionRepository.ModifyAsync(modifyResult.Data);

            await _unitOfWork.CommitAsync(autoRollback : true);

            return(Result.ReSuccess());
        }
        public virtual async Task <Result> Modify(PermissionActionModifyRequestDto dto)
        {
            //验证请求数据合法性
            var result = dto.Valid();

            if (!result.Success)
            {
                return(result);
            }

            //修改功能权限
            var modifyResult = await IocManager.Instance.Resolve <PermissionChangeService>()
                               .ModifyAction(dto.Id, dto.Name, dto.Description, dto.Enable, dto.ApiTemplate, dto.IsLogger, dto.HttpMethods.Select(f => new HttpMethod(f)).ToList());

            if (!modifyResult.Success)
            {
                return(modifyResult);
            }

            //数据持久化
            _operateLog.Record(ASFPermissions.PermissionModifyAction, dto, "Success");  //记录日志
            await _permissionRepository.ModifyAsync(modifyResult.Data);

            return(Result.ReSuccess());
        }