77 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			77 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using KonSoft.Shared.Hosting.AspNetCore;
 | |
| using KonSoft.Shared.Hosting.Microservices;
 | |
| using KonSoft.TenantManagement.EntityFrameworkCore;
 | |
| using Microsoft.AspNetCore.Builder;
 | |
| using Microsoft.Extensions.DependencyInjection;
 | |
| using Microsoft.Extensions.Hosting;
 | |
| using Volo.Abp;
 | |
| using Volo.Abp.BackgroundJobs;
 | |
| using Volo.Abp.Modularity;
 | |
| 
 | |
| namespace KonSoft.TenantManagement;
 | |
| 
 | |
| [DependsOn(
 | |
|     typeof(TenantManagementHttpApiModule),
 | |
|     typeof(TenantManagementApplicationModule),
 | |
|     typeof(TenantManagementEntityFrameworkCoreModule),
 | |
|     typeof(KonSoftSharedHostingMicroservicesModule)
 | |
| )]
 | |
| public class TenantManagementHttpApiHostModule : AbpModule
 | |
| {
 | |
|     public override void ConfigureServices(ServiceConfigurationContext context)
 | |
|     {
 | |
|         var configuration = context.Services.GetConfiguration();
 | |
| 
 | |
|         SwaggerConfigurationHelper.ConfigureWithOidc(
 | |
|             context,
 | |
|             configuration["AuthServer:Authority"]!,
 | |
|             ["TenantManagementService"],
 | |
|             discoveryEndpoint: configuration["AuthServer:MetadataAddress"],
 | |
|             apiTitle: "TenantManagement Service API"
 | |
|         );
 | |
| 
 | |
|         // 只发送事件,不处理事件
 | |
|         Configure<AbpBackgroundJobOptions>(options => options.IsJobExecutionEnabled = false);
 | |
|     }
 | |
| 
 | |
|     public override void OnApplicationInitialization(ApplicationInitializationContext context)
 | |
|     {
 | |
|         var app = context.GetApplicationBuilder();
 | |
|         var env = context.GetEnvironment();
 | |
| 
 | |
|         if (env.IsDevelopment())
 | |
|         {
 | |
|             app.UseDeveloperExceptionPage();
 | |
|         }
 | |
| 
 | |
|         app.UseAbpRequestLocalization();
 | |
|         app.UseCorrelationId();
 | |
|         app.UseStaticFiles();
 | |
|         app.UseRouting();
 | |
|         app.UseCors();
 | |
|         app.UseAuthentication();
 | |
| 
 | |
|         if (KonSoftConsts.MultiTenancyEnabled)
 | |
|         {
 | |
|             app.UseMultiTenancy();
 | |
|         }
 | |
| 
 | |
|         app.UseUnitOfWork();
 | |
|         app.UseDynamicClaims();
 | |
|         app.UseAuthorization();
 | |
| 
 | |
|         app.UseSwagger();
 | |
|         app.UseAbpSwaggerUI(options =>
 | |
|         {
 | |
|             options.SwaggerEndpoint("/swagger/v1/swagger.json", "TenantManagement API");
 | |
| 
 | |
|             var configuration = context.GetConfiguration();
 | |
|             options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
 | |
|             options.OAuthScopes("TenantManagement");
 | |
|         });
 | |
| 
 | |
|         app.UseAuditing();
 | |
|         app.UseAbpSerilogEnrichers();
 | |
|         app.UseConfiguredEndpoints();
 | |
|     }
 | |
| } |