diff --git a/Apimanager_backend.sln b/Apimanager_backend.sln
index 36300f7..f67a888 100644
--- a/Apimanager_backend.sln
+++ b/Apimanager_backend.sln
@@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35312.102
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apimanager_backend", "Apimanager_backend\Apimanager_backend.csproj", "{F4FD5145-6971-4032-B2B6-D7A61AF8BB2E}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Apimanager_backend", "Apimanager_backend\Apimanager_backend.csproj", "{F4FD5145-6971-4032-B2B6-D7A61AF8BB2E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Public", "Public\Public.csproj", "{3B2063E0-B7B1-4CCF-979C-0E533FE1A05E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +17,10 @@ Global
{F4FD5145-6971-4032-B2B6-D7A61AF8BB2E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F4FD5145-6971-4032-B2B6-D7A61AF8BB2E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F4FD5145-6971-4032-B2B6-D7A61AF8BB2E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3B2063E0-B7B1-4CCF-979C-0E533FE1A05E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3B2063E0-B7B1-4CCF-979C-0E533FE1A05E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3B2063E0-B7B1-4CCF-979C-0E533FE1A05E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3B2063E0-B7B1-4CCF-979C-0E533FE1A05E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/Apimanager_backend/ApiHandler/TestHandle.dll b/Apimanager_backend/ApiHandler/TestHandle.dll
new file mode 100644
index 0000000..8f80be3
Binary files /dev/null and b/Apimanager_backend/ApiHandler/TestHandle.dll differ
diff --git a/Apimanager_backend/Apimanager_backend.csproj b/Apimanager_backend/Apimanager_backend.csproj
index 059696b..bf92279 100644
--- a/Apimanager_backend/Apimanager_backend.csproj
+++ b/Apimanager_backend/Apimanager_backend.csproj
@@ -19,8 +19,14 @@
+
+
+
+
+
+
diff --git a/Apimanager_backend/Config/MyAutomapper.cs b/Apimanager_backend/Config/MyAutomapper.cs
index f0895eb..e032e04 100644
--- a/Apimanager_backend/Config/MyAutomapper.cs
+++ b/Apimanager_backend/Config/MyAutomapper.cs
@@ -15,6 +15,14 @@ namespace Apimanager_backend.Config
CreateMap();
CreateMap();
CreateMap();
+ CreateMap();
+ CreateMap();
+ CreateMap()
+ .ForMember(dest => dest.Success, opt => opt.MapFrom(src => src.code == 1))
+ .ForMember(dest => dest.QrCode, opt => opt.MapFrom(src => src.qrcode))
+ .ForMember(dest => dest.OrderNum, opt => opt.MapFrom(src => src.trade_no))
+ .ForMember(dest => dest.PayUrl, opt => opt.MapFrom(src => src.payurl))
+ .ForMember(dest => dest.Urlscheme, opt => opt.MapFrom(src => src.urlscheme));
}
}
}
diff --git a/Apimanager_backend/Config/ServiceCollectionExtensions.cs b/Apimanager_backend/Config/ServiceCollectionExtensions.cs
index 8f0a524..5f6c4f3 100644
--- a/Apimanager_backend/Config/ServiceCollectionExtensions.cs
+++ b/Apimanager_backend/Config/ServiceCollectionExtensions.cs
@@ -1,12 +1,15 @@
using Apimanager_backend.Dtos;
using Apimanager_backend.Services;
+using Apimanager_backend.Tools;
using Microsoft.AspNetCore.Authentication.JwtBearer;
+using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
+using Public;
using StackExchange.Redis;
-using System.ComponentModel;
-using System.Runtime.CompilerServices;
+using System.Reflection;
using System.Text;
+using System.Threading.RateLimiting;
namespace Apimanager_backend.Config
{
@@ -22,10 +25,17 @@ namespace Apimanager_backend.Config
services.AddScoped();
services.AddScoped();
services.AddScoped();
+ services.AddScoped();
+ services.AddScoped();
+ services.AddScoped();
services.AddScoped();
+ services.AddScoped();
+ services.AddScoped();
services.AddSingleton();
services.AddSingleton();
services.AddSingleton();
+ services.AddApiHandler(configuration);
+ services.AddRateLimit(configuration);
return services;
}
public static IServiceCollection AddJWTService(this IServiceCollection services,IConfiguration configuration)
@@ -100,5 +110,76 @@ namespace Apimanager_backend.Config
});
return services;
}
+ public static IServiceCollection AddApiHandler(this IServiceCollection services,IConfiguration configuration1)
+ {
+ /*
+ var handlerTypes = Assembly.GetExecutingAssembly()
+ .GetTypes()
+ .Where(t => typeof(IBillableApiHandler).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract);
+
+ foreach(var type in handlerTypes)
+ {
+ services.AddTransient(type);
+ }
+ */
+ services.AddSingleton();
+ var pluginLoaderService = services.BuildServiceProvider()
+ .GetRequiredService();
+ pluginLoaderService.LoadPlugins(services);
+
+
+ services.AddScoped();
+ return services;
+ }
+ public static IServiceCollection AddRateLimit(this IServiceCollection service, IConfiguration configuration1)
+ {
+ service.AddRateLimiter(option =>
+ {
+ option.RejectionStatusCode = 429;
+ option.OnRejected = async (context, ct) =>
+ {
+ context.HttpContext.Response.ContentType = "application/json";
+ await context.HttpContext.Response.WriteAsJsonAsync(new ResponseBase