You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
197 lines
7.9 KiB
197 lines
7.9 KiB
using LINGYUN.Abp.AspNetCore.HttpOverrides;
|
|
using LINGYUN.Abp.AspNetCore.Mvc.Localization;
|
|
using LINGYUN.Abp.AspNetCore.Mvc.Wrapper;
|
|
using LINGYUN.Abp.AuditLogging.Elasticsearch;
|
|
using LINGYUN.Abp.Authorization.OrganizationUnits;
|
|
using LINGYUN.Abp.Claims.Mapping;
|
|
using LINGYUN.Abp.Data.DbMigrator;
|
|
using LINGYUN.Abp.EventBus.CAP;
|
|
using LINGYUN.Abp.ExceptionHandling.Emailing;
|
|
using LINGYUN.Abp.Features.LimitValidation.Redis;
|
|
using LINGYUN.Abp.Identity.Session.AspNetCore;
|
|
using LINGYUN.Abp.Localization.CultureMap;
|
|
using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore;
|
|
using LINGYUN.Abp.Notifications;
|
|
using LINGYUN.Abp.OssManagement;
|
|
using LINGYUN.Abp.OssManagement.FileSystem;
|
|
using LINGYUN.Abp.OssManagement.Imaging;
|
|
using LINGYUN.Abp.OssManagement.SettingManagement;
|
|
using LINGYUN.Abp.Saas.EntityFrameworkCore;
|
|
using LINGYUN.Abp.Serilog.Enrichers.Application;
|
|
using LINGYUN.Abp.Serilog.Enrichers.UniqueId;
|
|
using LINGYUN.Abp.UI.Navigation.VueVbenAdmin;
|
|
using LINGYUN.Platform;
|
|
using LINGYUN.Platform.EntityFrameworkCore;
|
|
using LINGYUN.Platform.HttpApi;
|
|
using LINGYUN.Platform.Theme.VueVbenAdmin;
|
|
using LY.MicroService.Platform.EntityFrameworkCore;
|
|
using LY.MicroService.PlatformManagement.BackgroundWorkers;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Options;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp;
|
|
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
|
|
using Volo.Abp.AspNetCore.MultiTenancy;
|
|
using Volo.Abp.AspNetCore.Serilog;
|
|
using Volo.Abp.Autofac;
|
|
using Volo.Abp.BackgroundWorkers;
|
|
using Volo.Abp.BlobStoring;
|
|
using Volo.Abp.Caching.StackExchangeRedis;
|
|
using Volo.Abp.FeatureManagement.EntityFrameworkCore;
|
|
using Volo.Abp.Http.Client;
|
|
using Volo.Abp.Http.Client.IdentityModel.Web;
|
|
using Volo.Abp.Identity;
|
|
using Volo.Abp.Imaging;
|
|
using Volo.Abp.Modularity;
|
|
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
|
|
using Volo.Abp.SettingManagement.EntityFrameworkCore;
|
|
using Volo.Abp.Threading;
|
|
|
|
namespace LY.MicroService.PlatformManagement;
|
|
|
|
[DependsOn(
|
|
typeof(AbpSerilogEnrichersApplicationModule),
|
|
typeof(AbpSerilogEnrichersUniqueIdModule),
|
|
typeof(AbpAspNetCoreSerilogModule),
|
|
typeof(AbpAuditLoggingElasticsearchModule),
|
|
typeof(AbpAspNetCoreMultiTenancyModule),
|
|
typeof(AbpAspNetCoreMvcLocalizationModule),
|
|
typeof(AbpUINavigationVueVbenAdminModule),
|
|
typeof(PlatformThemeVueVbenAdminModule),
|
|
// typeof(AbpOssManagementAliyunModule),
|
|
typeof(AbpOssManagementFileSystemModule), // 本地文件系统提供者模块
|
|
typeof(AbpOssManagementImagingModule), // 本地文件系统图形处理模块
|
|
typeof(AbpOssManagementApplicationModule),
|
|
typeof(AbpOssManagementHttpApiModule),
|
|
typeof(AbpOssManagementSettingManagementModule),
|
|
typeof(AbpImagingImageSharpModule),
|
|
typeof(PlatformApplicationModule),
|
|
typeof(PlatformHttpApiModule),
|
|
typeof(PlatformEntityFrameworkCoreModule),
|
|
typeof(AbpIdentityHttpApiClientModule),
|
|
typeof(AbpHttpClientIdentityModelWebModule),
|
|
typeof(AbpFeatureManagementEntityFrameworkCoreModule),
|
|
typeof(AbpSaasEntityFrameworkCoreModule),
|
|
typeof(AbpSettingManagementEntityFrameworkCoreModule),
|
|
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
|
|
typeof(AbpLocalizationManagementEntityFrameworkCoreModule),
|
|
typeof(PlatformMigrationsEntityFrameworkCoreModule),
|
|
typeof(AbpDataDbMigratorModule),
|
|
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
|
|
typeof(AbpAuthorizationOrganizationUnitsModule),
|
|
typeof(AbpNotificationsModule),
|
|
typeof(AbpEmailingExceptionHandlingModule),
|
|
typeof(AbpCAPEventBusModule),
|
|
typeof(AbpFeaturesValidationRedisModule),
|
|
// typeof(AbpFeaturesClientModule),// 当需要客户端特性限制时取消注释此模块
|
|
// typeof(AbpFeaturesValidationRedisClientModule),// 当需要客户端特性限制时取消注释此模块
|
|
typeof(AbpCachingStackExchangeRedisModule),
|
|
typeof(AbpLocalizationCultureMapModule),
|
|
typeof(AbpIdentitySessionAspNetCoreModule),
|
|
typeof(AbpHttpClientModule),
|
|
typeof(AbpAspNetCoreMvcWrapperModule),
|
|
typeof(AbpClaimsMappingModule),
|
|
typeof(AbpAspNetCoreHttpOverridesModule),
|
|
typeof(AbpAutofacModule)
|
|
)]
|
|
public partial class PlatformManagementHttpApiHostModule : AbpModule
|
|
{
|
|
public override void PreConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
var configuration = context.Services.GetConfiguration();
|
|
|
|
PreConfigureWrapper();
|
|
PreForwardedHeaders();
|
|
PreConfigureFeature();
|
|
PreConfigureApp(configuration);
|
|
PreConfigureCAP(configuration);
|
|
}
|
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
var hostingEnvironment = context.Services.GetHostingEnvironment();
|
|
var configuration = context.Services.GetConfiguration();
|
|
|
|
ConfigureWrapper();
|
|
ConfigureDbContext();
|
|
ConfigureBlobStoring();
|
|
ConfigureLocalization();
|
|
ConfigureKestrelServer();
|
|
ConfigureExceptionHandling();
|
|
ConfigureVirtualFileSystem();
|
|
ConfigureFeatureManagement();
|
|
ConfigureTiming(configuration);
|
|
ConfigureCaching(configuration);
|
|
ConfigureIdentity(configuration);
|
|
ConfigureAuditing(configuration);
|
|
ConfigureSwagger(context.Services);
|
|
ConfigureMultiTenancy(configuration);
|
|
ConfigureJsonSerializer(configuration);
|
|
ConfigureMvc(context.Services, configuration);
|
|
ConfigureCors(context.Services, configuration);
|
|
ConfigureOpenTelemetry(context.Services, configuration);
|
|
ConfigureDistributedLocking(context.Services, configuration);
|
|
ConfigureSeedWorker(context.Services, hostingEnvironment.IsDevelopment());
|
|
ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment());
|
|
}
|
|
|
|
public override void OnPostApplicationInitialization(ApplicationInitializationContext context)
|
|
{
|
|
AsyncHelper.RunSync(() => OnPostApplicationInitializationAsync(context));
|
|
}
|
|
|
|
public async override Task OnPostApplicationInitializationAsync(ApplicationInitializationContext context)
|
|
{
|
|
var options = context.ServiceProvider.GetRequiredService<IOptions<AbpOssManagementOptions>>().Value;
|
|
if (options.IsCleanupEnabled)
|
|
{
|
|
await context.ServiceProvider
|
|
.GetRequiredService<IBackgroundWorkerManager>()
|
|
.AddAsync(context.ServiceProvider.GetRequiredService<OssObjectTempCleanupBackgroundWorker>());
|
|
}
|
|
}
|
|
|
|
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
|
{
|
|
var app = context.GetApplicationBuilder();
|
|
var env = context.GetEnvironment();
|
|
|
|
app.UseForwardedHeaders();
|
|
// 本地化
|
|
app.UseMapRequestLocalization();
|
|
// http调用链
|
|
app.UseCorrelationId();
|
|
// 虚拟文件系统
|
|
app.UseStaticFiles();
|
|
// 路由
|
|
app.UseRouting();
|
|
// 跨域
|
|
app.UseCors(DefaultCorsPolicyName);
|
|
// 认证
|
|
app.UseAuthentication();
|
|
app.UseJwtTokenMiddleware();
|
|
// 多租户
|
|
app.UseMultiTenancy();
|
|
// 会话
|
|
app.UseAbpSession();
|
|
app.UseDynamicClaims();
|
|
// 授权
|
|
app.UseAuthorization();
|
|
// Swagger
|
|
app.UseSwagger();
|
|
// Swagger可视化界面
|
|
app.UseSwaggerUI(options =>
|
|
{
|
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support Platform API");
|
|
});
|
|
// 审计日志
|
|
app.UseAuditing();
|
|
// 记录请求信息
|
|
app.UseAbpSerilogEnrichers();
|
|
// 路由
|
|
app.UseConfiguredEndpoints();
|
|
}
|
|
}
|
|
|