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.
164 lines
6.5 KiB
164 lines
6.5 KiB
using DotNetCore.CAP;
|
|
using LINGYUN.Abp.AspNetCore.HttpOverrides;
|
|
using LINGYUN.Abp.AspNetCore.Mvc.Localization;
|
|
using LINGYUN.Abp.Auditing;
|
|
using LINGYUN.Abp.AuditLogging.Elasticsearch;
|
|
using LINGYUN.Abp.CachingManagement;
|
|
using LINGYUN.Abp.CachingManagement.StackExchangeRedis;
|
|
using LINGYUN.Abp.Data.DbMigrator;
|
|
using LINGYUN.Abp.EventBus.CAP;
|
|
using LINGYUN.Abp.ExceptionHandling.Emailing;
|
|
using LINGYUN.Abp.FeatureManagement;
|
|
using LINGYUN.Abp.Identity.EntityFrameworkCore;
|
|
using LINGYUN.Abp.Localization.CultureMap;
|
|
using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore;
|
|
using LINGYUN.Abp.Logging.Serilog.Elasticsearch;
|
|
using LINGYUN.Abp.PermissionManagement.OrganizationUnits;
|
|
using LINGYUN.Abp.Saas;
|
|
using LINGYUN.Abp.Saas.EntityFrameworkCore;
|
|
using LINGYUN.Abp.Serilog.Enrichers.Application;
|
|
using LINGYUN.Abp.Serilog.Enrichers.UniqueId;
|
|
using LINGYUN.Abp.SettingManagement;
|
|
using LINGYUN.Abp.Sms.Aliyun;
|
|
using LINGYUN.Abp.TextTemplating;
|
|
using LINGYUN.Abp.TextTemplating.EntityFrameworkCore;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using System.Linq;
|
|
using Volo.Abp;
|
|
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
|
|
using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy;
|
|
using Volo.Abp.AspNetCore.Serilog;
|
|
using Volo.Abp.Autofac;
|
|
using Volo.Abp.Caching.StackExchangeRedis;
|
|
using Volo.Abp.EntityFrameworkCore.MySQL;
|
|
using Volo.Abp.FeatureManagement;
|
|
using Volo.Abp.FeatureManagement.EntityFrameworkCore;
|
|
using Volo.Abp.IdentityServer.EntityFrameworkCore;
|
|
using Volo.Abp.Modularity;
|
|
using Volo.Abp.PermissionManagement;
|
|
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
|
|
using Volo.Abp.PermissionManagement.HttpApi;
|
|
using Volo.Abp.PermissionManagement.Identity;
|
|
using Volo.Abp.PermissionManagement.IdentityServer;
|
|
using Volo.Abp.SettingManagement.EntityFrameworkCore;
|
|
|
|
namespace LY.MicroService.BackendAdmin;
|
|
|
|
[DependsOn(
|
|
typeof(AbpSerilogEnrichersApplicationModule),
|
|
typeof(AbpSerilogEnrichersUniqueIdModule),
|
|
typeof(AbpAspNetCoreSerilogModule),
|
|
typeof(AbpLoggingSerilogElasticsearchModule),
|
|
typeof(AbpAuditLoggingElasticsearchModule),
|
|
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
|
|
typeof(AbpAspNetCoreMvcLocalizationModule),
|
|
typeof(AbpSettingManagementApplicationModule),
|
|
typeof(AbpSettingManagementHttpApiModule),
|
|
typeof(AbpPermissionManagementApplicationModule),
|
|
typeof(AbpPermissionManagementHttpApiModule),
|
|
typeof(AbpFeatureManagementApplicationModule),
|
|
typeof(AbpFeatureManagementHttpApiModule),
|
|
typeof(AbpFeatureManagementClientModule),
|
|
typeof(AbpAuditingApplicationModule),
|
|
typeof(AbpAuditingHttpApiModule),
|
|
typeof(AbpSaasApplicationModule),
|
|
typeof(AbpSaasHttpApiModule),
|
|
typeof(AbpTextTemplatingApplicationModule),
|
|
typeof(AbpTextTemplatingHttpApiModule),
|
|
typeof(AbpCachingManagementApplicationModule),
|
|
typeof(AbpCachingManagementHttpApiModule),
|
|
typeof(AbpCachingManagementStackExchangeRedisModule),
|
|
typeof(AbpEntityFrameworkCoreMySQLModule),
|
|
typeof(AbpIdentityEntityFrameworkCoreModule),// 用户角色权限需要引用包
|
|
typeof(AbpIdentityServerEntityFrameworkCoreModule), // 客户端权限需要引用包
|
|
typeof(AbpPermissionManagementDomainOrganizationUnitsModule), // 组织机构权限管理
|
|
typeof(AbpSaasEntityFrameworkCoreModule),
|
|
typeof(AbpSettingManagementEntityFrameworkCoreModule),
|
|
typeof(AbpPermissionManagementDomainIdentityModule),
|
|
typeof(AbpPermissionManagementDomainIdentityServerModule),
|
|
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
|
|
typeof(AbpFeatureManagementEntityFrameworkCoreModule),
|
|
typeof(AbpLocalizationManagementEntityFrameworkCoreModule),
|
|
typeof(AbpTextTemplatingEntityFrameworkCoreModule),
|
|
typeof(AbpDataDbMigratorModule),
|
|
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
|
|
typeof(AbpEmailingExceptionHandlingModule),
|
|
typeof(AbpCAPEventBusModule),
|
|
typeof(AbpAliyunSmsModule),
|
|
typeof(AbpCachingStackExchangeRedisModule),
|
|
typeof(AbpAspNetCoreHttpOverridesModule),
|
|
typeof(AbpLocalizationCultureMapModule),
|
|
typeof(AbpAutofacModule)
|
|
)]
|
|
public partial class BackendAdminHttpApiHostModule : AbpModule
|
|
{
|
|
public override void PreConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
var configuration = context.Services.GetConfiguration();
|
|
|
|
PreConfigureApp();
|
|
PreConfigureFeature();
|
|
PreConfigureCAP(configuration);
|
|
}
|
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
var hostingEnvironment = context.Services.GetHostingEnvironment();
|
|
var configuration = context.Services.GetConfiguration();
|
|
|
|
ConfigureDbContext();
|
|
ConfigureLocalization();
|
|
ConfigureJsonSerializer();
|
|
ConfigureExceptionHandling();
|
|
ConfigureVirtualFileSystem();
|
|
ConfigureFeatureManagement();
|
|
ConfigurePermissionManagement();
|
|
ConfigureCaching(configuration);
|
|
ConfigureAuditing(configuration);
|
|
ConfigureSwagger(context.Services);
|
|
ConfigureMultiTenancy(configuration);
|
|
ConfigureCors(context.Services, configuration);
|
|
ConfigureSeedWorker(context.Services, hostingEnvironment.IsDevelopment());
|
|
ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment());
|
|
}
|
|
|
|
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
|
{
|
|
var app = context.GetApplicationBuilder();
|
|
// 本地化
|
|
app.UseMapRequestLocalization();
|
|
// http调用链
|
|
app.UseCorrelationId();
|
|
// 虚拟文件系统
|
|
app.UseStaticFiles();
|
|
// 路由
|
|
app.UseRouting();
|
|
// 跨域
|
|
app.UseCors(DefaultCorsPolicyName);
|
|
// 认证
|
|
app.UseAuthentication();
|
|
// jwt
|
|
app.UseJwtTokenMiddleware();
|
|
// 多租户
|
|
app.UseMultiTenancy();
|
|
// 授权
|
|
app.UseAuthorization();
|
|
// Cap Dashboard
|
|
app.UseCapDashboard();
|
|
// Swagger
|
|
app.UseSwagger();
|
|
// Swagger可视化界面
|
|
app.UseSwaggerUI(options =>
|
|
{
|
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support BackendAdmin API");
|
|
});
|
|
// 审计日志
|
|
app.UseAuditing();
|
|
app.UseAbpSerilogEnrichers();
|
|
// 路由
|
|
app.UseConfiguredEndpoints();
|
|
}
|
|
}
|
|
|