mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2026-03-10 00:13:36 +08:00
Merge branch 'main' of https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
@@ -17,21 +17,21 @@ namespace SKIT.FlurlHttpClient.Wechat.Api.Sample
|
|||||||
{
|
{
|
||||||
services.AddControllers();
|
services.AddControllers();
|
||||||
|
|
||||||
// ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD> `appsettings.json` <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
// 注入配置项(内容见 `appsettings.json` 文件)
|
||||||
services.AddOptions();
|
services.AddOptions();
|
||||||
services.Configure<Options.WechatOptions>(Configuration.GetSection(nameof(Options.WechatOptions)));
|
services.Configure<Options.WechatOptions>(Configuration.GetSection(nameof(Options.WechatOptions)));
|
||||||
|
|
||||||
// ע<EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD>ʽ<EFBFBD><EFBFBD>
|
// 注入分布式锁
|
||||||
services.AddSingleton<Services.DistributedLock.IDistributedLockFactory, Services.DistributedLock.Implements.DistributedLockFactory>();
|
services.AddSingleton<Services.DistributedLock.IDistributedLockFactory, Services.DistributedLock.Implements.DistributedLockFactory>();
|
||||||
|
|
||||||
// ע<EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD><EFBFBD>
|
// 注入仓储类
|
||||||
services.AddSingleton<Services.Repositories.IWechatAccessTokenEntityRepository, Services.Repositories.Implements.WechatAccessTokenEntityRepository>();
|
services.AddSingleton<Services.Repositories.IWechatAccessTokenEntityRepository, Services.Repositories.Implements.WechatAccessTokenEntityRepository>();
|
||||||
|
|
||||||
// ע<EFBFBD>빤<EFBFBD><EFBFBD> HTTP <EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD>
|
// 注入工厂 HTTP 客户端
|
||||||
services.AddHttpClient();
|
services.AddHttpClient();
|
||||||
services.AddSingleton<Services.HttpClients.IWechatApiHttpClientFactory, Services.HttpClients.Implements.WechatApiHttpClientFactory>();
|
services.AddSingleton<Services.HttpClients.IWechatApiHttpClientFactory, Services.HttpClients.Implements.WechatApiHttpClientFactory>();
|
||||||
|
|
||||||
// ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 注入后台任务
|
||||||
services.AddHostedService<Services.BackgroundServices.WechatAccessTokenRefreshingBackgroundService>();
|
services.AddHostedService<Services.BackgroundServices.WechatAccessTokenRefreshingBackgroundService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
@@ -18,16 +18,16 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample
|
|||||||
{
|
{
|
||||||
services.AddControllers();
|
services.AddControllers();
|
||||||
|
|
||||||
// ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD> `appsettings.json` <EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>
|
// 注入配置项(内容见 `appsettings.json` 文件)
|
||||||
services.AddOptions();
|
services.AddOptions();
|
||||||
services.Configure<Options.TenpayOptions>(Configuration.GetSection(nameof(Options.TenpayOptions)));
|
services.Configure<Options.TenpayOptions>(Configuration.GetSection(nameof(Options.TenpayOptions)));
|
||||||
|
|
||||||
// ע<EFBFBD>빤<EFBFBD><EFBFBD> HTTP <EFBFBD>ͻ<EFBFBD><EFBFBD><EFBFBD>
|
// 注入工厂 HTTP 客户端
|
||||||
services.AddHttpClient();
|
services.AddHttpClient();
|
||||||
services.AddSingleton<Services.HttpClients.IWechatTenpayCertificateManagerFactory, Services.HttpClients.Implements.WechatTenpayCertificateManagerFactory>();
|
services.AddSingleton<Services.HttpClients.IWechatTenpayCertificateManagerFactory, Services.HttpClients.Implements.WechatTenpayCertificateManagerFactory>();
|
||||||
services.AddSingleton<Services.HttpClients.IWechatTenpayHttpClientFactory, Services.HttpClients.Implements.WechatTenpayHttpClientFactory>();
|
services.AddSingleton<Services.HttpClients.IWechatTenpayHttpClientFactory, Services.HttpClients.Implements.WechatTenpayHttpClientFactory>();
|
||||||
|
|
||||||
// ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 注入后台任务
|
||||||
services.AddHostedService<Services.BackgroundServices.TenpayCertificateRefreshingBackgroundService>();
|
services.AddHostedService<Services.BackgroundServices.TenpayCertificateRefreshingBackgroundService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
"Default": "Information",
|
"Default": "Information",
|
||||||
@@ -12,10 +12,10 @@
|
|||||||
"TenpayOptions": {
|
"TenpayOptions": {
|
||||||
"Merchants": [
|
"Merchants": [
|
||||||
{
|
{
|
||||||
"MerchantId": "<EFBFBD><EFBFBD>д<EFBFBD>̻<EFBFBD><EFBFBD><EFBFBD>",
|
"MerchantId": "填写商户号",
|
||||||
"SecretV3": "<EFBFBD><EFBFBD>д<EFBFBD>̻<EFBFBD> V3 API <EFBFBD><EFBFBD>Կ",
|
"SecretV3": "填写商户 V3 API 密钥",
|
||||||
"CertSerialNumber": "<EFBFBD><EFBFBD>д<EFBFBD>̻<EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>к<EFBFBD>",
|
"CertSerialNumber": "填写商户证书序列号",
|
||||||
"CertPrivateKey": "<EFBFBD><EFBFBD>д<EFBFBD>̻<EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
|
"CertPrivateKey": "填写商户证书文件内容"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"NotifyUrl": "https://localhost:5001"
|
"NotifyUrl": "https://localhost:5001"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample
|
namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample
|
||||||
{
|
{
|
||||||
public class WebApiApplication : HttpApplication
|
public class WebApiApplication : HttpApplication
|
||||||
{
|
{
|
||||||
@@ -6,22 +6,22 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV3.Sample
|
|||||||
|
|
||||||
protected void Application_Start()
|
protected void Application_Start()
|
||||||
{
|
{
|
||||||
// ע<EFBFBD><EFBFBD> WebAPI <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 注册 WebAPI 区域
|
||||||
AreaRegistration.RegisterAllAreas();
|
AreaRegistration.RegisterAllAreas();
|
||||||
|
|
||||||
// ע<EFBFBD><EFBFBD> WebAPI <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 注册 WebAPI 配置
|
||||||
GlobalConfiguration.Configure(WebApiConfiguration.Register);
|
GlobalConfiguration.Configure(WebApiConfiguration.Register);
|
||||||
|
|
||||||
// ע<EFBFBD><EFBFBD>ȫ<EFBFBD>ֹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 注册全局过滤器
|
||||||
FilterRegistration.RegisterGlobalFilters(GlobalFilters.Filters);
|
FilterRegistration.RegisterGlobalFilters(GlobalFilters.Filters);
|
||||||
|
|
||||||
// ע<EFBFBD><EFBFBD>·<EFBFBD>ɱ<EFBFBD>
|
// 注册路由表
|
||||||
RouteRegistration.RegisterRoutes(RouteTable.Routes);
|
RouteRegistration.RegisterRoutes(RouteTable.Routes);
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD> Autofac <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ע<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 初始化 Autofac 依赖注入容器
|
||||||
AutofacInitializer.Init();
|
AutofacInitializer.Init();
|
||||||
|
|
||||||
// <EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD> Hangfire <EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
// 初始化 Hangfire 定时任务
|
||||||
_backgroundJobServer = HangfireInitializer.Init();
|
_backgroundJobServer = HangfireInitializer.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ namespace SKIT.FlurlHttpClient.Wechat.TenpayV2.UnitTests
|
|||||||
{
|
{
|
||||||
public class TestCase_JsonConverterTests
|
public class TestCase_JsonConverterTests
|
||||||
{
|
{
|
||||||
[Fact(DisplayName = "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮ `FlattenNArrayObjectConverterBase`")]
|
[Fact(DisplayName = "测试用例:自定义转换器之 `FlattenNArrayObjectConverterBase`")]
|
||||||
public void TestFlattenNArrayObjectConverter()
|
public void TestFlattenNArrayObjectConverter()
|
||||||
{
|
{
|
||||||
var newtonsoftJsonSerializer = new FlurlNewtonsoftJsonSerializer();
|
var newtonsoftJsonSerializer = new FlurlNewtonsoftJsonSerializer();
|
||||||
|
|||||||
Reference in New Issue
Block a user