mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 18:43:26 +08:00
后端【升级】:更新所有后端组件到最新版本,调整initq消息队列的使用方法,调整skit微信交互组件的使用方法。
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.2" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="2.36.0" />
|
||||
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="3.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Flurl;
|
||||
using Flurl.Http;
|
||||
@@ -22,8 +23,6 @@ namespace CoreCms.Net.WeChat.Service.HttpClients
|
||||
{
|
||||
_httpClientFactory = httpClientFactory;
|
||||
_weChatOptions = weChatOptions.Value;
|
||||
|
||||
FlurlHttp.GlobalSettings.FlurlClientFactory = new DelegatingFlurlClientFactory(_httpClientFactory);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -35,16 +34,17 @@ namespace CoreCms.Net.WeChat.Service.HttpClients
|
||||
if (string.IsNullOrEmpty(_weChatOptions.WeiXinAppId) || string.IsNullOrEmpty(_weChatOptions.WeiXinAppSecret))
|
||||
throw new Exception("未在配置项中找到微信公众号配置讯息。");
|
||||
|
||||
var wechatApiClient = new WechatApiClient(new WechatApiClientOptions()
|
||||
var wechatApiClientOptions = new WechatApiClientOptions()
|
||||
{
|
||||
AppId = _weChatOptions.WeiXinAppId,
|
||||
AppSecret = _weChatOptions.WeiXinAppSecret,
|
||||
});
|
||||
PushEncodingAESKey = _weChatOptions.WeiXinEncodingAesKey,
|
||||
PushToken = _weChatOptions.WeiXinToken
|
||||
};
|
||||
|
||||
wechatApiClient.Configure(settings =>
|
||||
{
|
||||
settings.JsonSerializer = new FlurlNewtonsoftJsonSerializer();
|
||||
});
|
||||
var wechatApiClient = WechatApiClientBuilder.Create(wechatApiClientOptions)
|
||||
.UseHttpClient(_httpClientFactory.CreateClient(), disposeClient: false)
|
||||
.Build();
|
||||
|
||||
return wechatApiClient;
|
||||
}
|
||||
@@ -58,41 +58,19 @@ namespace CoreCms.Net.WeChat.Service.HttpClients
|
||||
if (string.IsNullOrEmpty(_weChatOptions.WxOpenAppId) || string.IsNullOrEmpty(_weChatOptions.WxOpenAppSecret))
|
||||
throw new Exception("未在配置项中找到微信小程序配置讯息。");
|
||||
|
||||
var WechatApiClient = new WechatApiClient(new WechatApiClientOptions()
|
||||
var wechatApiClientOptions = new WechatApiClientOptions()
|
||||
{
|
||||
AppId = _weChatOptions.WxOpenAppId,
|
||||
AppSecret = _weChatOptions.WxOpenAppSecret
|
||||
});
|
||||
AppSecret = _weChatOptions.WxOpenAppSecret,
|
||||
PushEncodingAESKey = _weChatOptions.WxOpenEncodingAESKey,
|
||||
PushToken = _weChatOptions.WxOpenToken
|
||||
};
|
||||
|
||||
WechatApiClient.Configure(settings =>
|
||||
{
|
||||
settings.JsonSerializer = new FlurlNewtonsoftJsonSerializer();
|
||||
});
|
||||
var wechatApiClient = WechatApiClientBuilder.Create(wechatApiClientOptions)
|
||||
.UseHttpClient(_httpClientFactory.CreateClient(), disposeClient: false)
|
||||
.Build();
|
||||
|
||||
return WechatApiClient;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class WeChatApiHttpClientFactory
|
||||
{
|
||||
internal class DelegatingFlurlClientFactory : IFlurlClientFactory
|
||||
{
|
||||
private readonly System.Net.Http.IHttpClientFactory _httpClientFactory;
|
||||
|
||||
public DelegatingFlurlClientFactory(System.Net.Http.IHttpClientFactory httpClientFactory)
|
||||
{
|
||||
_httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory));
|
||||
}
|
||||
|
||||
public IFlurlClient Get(Url url)
|
||||
{
|
||||
return new FlurlClient(_httpClientFactory.CreateClient(url.ToUri().Host));
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Do Nothing
|
||||
}
|
||||
return wechatApiClient;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user