Ejemplo n.º 1
0
        public async Task <Result> CreateOpenApi([FromBody] PermissionOpenApiCreateRequestDto dto)
        {
            //验证请求数据合法性
            var result = dto.Valid();

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

            //创建菜单权限
            var permission = dto.To();

            result = this._serviceProvider.GetRequiredService <PermissionCreateService>().CreateOpenApi(permission);
            if (!result.Success)
            {
                return(result);
            }

            //数据持久化
            _operateLog.Record(ASFPermissions.PermissionCreateOpenApi, dto, "Success");  //记录日志
            await _permissionRepository.AddAsync(permission);

            await _unitOfWork.CommitAsync(autoRollback : true);

            return(Result.ReSuccess());
        }
Ejemplo n.º 2
0
        public async Task <Result> Create(PermissionOpenApiCreateRequestDto dto)
        {
            //验证请求数据合法性
            var result = dto.Valid();

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

            //创建菜单权限
            var permission = dto.To();

            result = IocManager.Instance.Resolve <PermissionCreateService>().CreateOpenApi(permission);
            if (!result.Success)
            {
                return(result);
            }

            //数据持久化
            _operateLog.Record(ASFPermissions.PermissionCreateOpenApi, dto, "Success");  //记录日志
            await _permissionRepository.AddAsync(permission);

            return(Result.ReSuccess());
        }