public async Task <ApiResult <bool> > Publish([FromBody] ApiResourcePublishModel value)
        {
            if (!ModelState.IsValid)
            {
                return(new ApiResult <bool>(l, BasicControllerCodes.UnprocessableEntity,
                                            ModelErrors()));
            }

            if (!await exists(value.id))
            {
                return(new ApiResult <bool>(l, BasicControllerCodes.NotFound));
            }

            #region 如果 oauth2 或 productId为空,从租户配置读取默认配置
            if (string.IsNullOrWhiteSpace(value.authorizationServerId) &&
                Tenant.properties.ContainsKey(AzureApiManagementConsts.AuthorizationServerId))
            {
                value.authorizationServerId = Tenant.properties[AzureApiManagementConsts.AuthorizationServerId];
            }

            if (string.IsNullOrWhiteSpace(value.productId) &&
                Tenant.properties.ContainsKey(AzureApiManagementConsts.ProductId))
            {
                value.productId = Tenant.properties[AzureApiManagementConsts.ProductId];
            }
            #endregion

            // 发布或更新微服务到网关
            var result = await AzureApim.Apis.ImportOrUpdateAsync(
                value.id.ToString(),
                value.suffix,
                value.swaggerUrl,
                value.productId,
                value.authorizationServerId,
                value.scope,
                value.openid);

            // 更新微服务策略
            if (result && !string.IsNullOrWhiteSpace(value.policy))
            {
                await AzureApim.Apis.SetPolicyAsync(value.id.ToString(), value.policy);
            }

            var publishKey = $"ApiResource:Publish:{value.id}";

            await redis.Set(publishKey, JsonConvert.SerializeObject(value), null);

            return(new ApiResult <bool>(result));
        }
        public async Task <ApiResult <ApiResourcePublishModel> > PublishSetting(int id)
        {
            if (!await exists(id))
            {
                return(new ApiResult <ApiResourcePublishModel>(l, BasicControllerCodes.NotFound));
            }

            ApiResourcePublishModel result = null;

            var publishKey = $"ApiResource:Publish:{id}";

            var resultCache = await redis.Get(publishKey);

            if (!string.IsNullOrWhiteSpace(resultCache))
            {
                result = JsonConvert.DeserializeObject <ApiResourcePublishModel>(resultCache);
            }

            return(new ApiResult <ApiResourcePublishModel>(result));
        }