2025-08-22 09:12:19 +08:00
|
|
|
using JiShe.ServicePro.Core;
|
2025-08-27 17:28:40 +08:00
|
|
|
using JiShe.ServicePro.PulsarProvider.Internal;
|
2025-06-18 16:04:41 +08:00
|
|
|
using JiShe.ServicePro.SwaggerConfigs;
|
|
|
|
|
using System.Reflection;
|
2025-05-27 22:53:46 +08:00
|
|
|
using Volo.Abp.BlobStoring.FileSystem;
|
|
|
|
|
|
2025-05-27 14:27:50 +08:00
|
|
|
namespace JiShe.IoT
|
2025-05-27 14:02:24 +08:00
|
|
|
{
|
|
|
|
|
[DependsOn(
|
2025-05-27 14:27:50 +08:00
|
|
|
typeof(IoTHttpApiModule),
|
2025-05-27 14:02:24 +08:00
|
|
|
typeof(ServiceProSharedHostingMicroserviceModule),
|
|
|
|
|
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
|
2025-05-27 14:27:50 +08:00
|
|
|
typeof(IoTEntityFrameworkCoreModule),
|
2025-05-27 14:02:24 +08:00
|
|
|
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
|
|
|
|
|
typeof(AbpAspNetCoreSerilogModule),
|
|
|
|
|
typeof(AbpAccountWebModule),
|
2025-05-27 14:27:50 +08:00
|
|
|
typeof(IoTApplicationModule),
|
2025-05-27 14:02:24 +08:00
|
|
|
// typeof(AbpProCapModule),
|
|
|
|
|
// typeof(AbpProCapEntityFrameworkCoreModule),
|
|
|
|
|
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
|
|
|
|
|
typeof(AbpCachingStackExchangeRedisModule),
|
2025-05-27 22:53:46 +08:00
|
|
|
typeof(AbpBlobStoringFileSystemModule),
|
2025-05-27 14:02:24 +08:00
|
|
|
typeof(AbpDistributedLockingModule)
|
2025-07-25 17:27:21 +08:00
|
|
|
//typeof(AbpBackgroundJobsHangfireModule)
|
2025-05-27 14:02:24 +08:00
|
|
|
)]
|
2025-05-27 14:27:50 +08:00
|
|
|
public partial class IoTHttpApiHostModule : AbpModule
|
2025-05-27 14:02:24 +08:00
|
|
|
{
|
|
|
|
|
public override void OnPostApplicationInitialization(ApplicationInitializationContext context)
|
|
|
|
|
{
|
|
|
|
|
// 应用程序初始化的时候注册hangfire
|
|
|
|
|
//context.CreateRecurringJob();
|
|
|
|
|
base.OnPostApplicationInitialization(context);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
|
|
|
{
|
|
|
|
|
var configuration = context.Services.GetConfiguration();
|
|
|
|
|
ConfigureCache(context);
|
|
|
|
|
ConfigurationDistributedLocking(context);
|
|
|
|
|
ConfigureSwaggerServices(context);
|
|
|
|
|
ConfigureJwtAuthentication(context, configuration);
|
|
|
|
|
//ConfigureHangfire(context);
|
|
|
|
|
ConfigureMiniProfiler(context);
|
|
|
|
|
ConfigureIdentity(context);
|
|
|
|
|
//ConfigureCap(context);
|
|
|
|
|
ConfigureAuditLog(context);
|
|
|
|
|
ConfigurationSignalR(context);
|
|
|
|
|
ConfigurationMultiTenancy();
|
2025-05-27 22:53:46 +08:00
|
|
|
ConfigureBlobStorage();
|
2025-09-09 17:12:41 +08:00
|
|
|
|
2025-08-22 09:12:19 +08:00
|
|
|
Configure<DataChannelOptions>(options =>
|
|
|
|
|
{
|
|
|
|
|
configuration.GetSection(nameof(DataChannelOptions)).Bind(options);
|
|
|
|
|
});
|
2025-05-27 14:02:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
|
|
|
|
{
|
|
|
|
|
var app = context.GetApplicationBuilder();
|
|
|
|
|
var configuration = context.GetConfiguration();
|
|
|
|
|
app.UseServiceProRequestLocalization();
|
|
|
|
|
app.UseCorrelationId();
|
|
|
|
|
app.MapAbpStaticAssets();
|
|
|
|
|
if (configuration.GetValue("MiniProfiler:Enabled", false))
|
|
|
|
|
{
|
|
|
|
|
app.UseMiniProfiler();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.UseRouting();
|
2025-05-27 14:27:50 +08:00
|
|
|
app.UseCors(IoTHttpApiHostConst.DefaultCorsPolicyName);
|
2025-05-27 14:02:24 +08:00
|
|
|
app.UseAuthentication();
|
|
|
|
|
|
|
|
|
|
if (MultiTenancyConsts.IsEnabled)
|
|
|
|
|
{
|
|
|
|
|
app.UseMultiTenancy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
app.UseSwagger();
|
|
|
|
|
app.UseAbpSwaggerUI(options =>
|
|
|
|
|
{
|
2025-06-18 16:57:45 +08:00
|
|
|
var groupNames = EnumExtensions.GetEnumTypeValueNameList<SwaggerGroupEnum>();
|
2025-06-19 11:36:07 +08:00
|
|
|
var excludeSwaggerGroups = configuration.GetSection("ExcludeSwaggerGroup").Get<List<string>>() ?? new List<string>();
|
2025-07-25 17:27:21 +08:00
|
|
|
groupNames.ForEach(attr =>
|
|
|
|
|
{
|
2025-06-18 16:04:41 +08:00
|
|
|
|
2025-06-19 11:36:07 +08:00
|
|
|
if (!excludeSwaggerGroups.Where(e => e == attr.Key).Any())
|
|
|
|
|
{
|
|
|
|
|
options.SwaggerEndpoint($"/swagger/{attr.Key}/swagger.json", attr.Value);
|
|
|
|
|
}
|
2025-06-18 16:04:41 +08:00
|
|
|
});
|
2025-06-19 11:36:07 +08:00
|
|
|
|
2025-07-28 17:10:05 +08:00
|
|
|
options.SwaggerEndpoint("/swagger/AbpPro/swagger.json", "AbpPro API");
|
2025-06-18 16:04:41 +08:00
|
|
|
|
2025-05-27 14:02:24 +08:00
|
|
|
options.DocExpansion(DocExpansion.None);
|
|
|
|
|
options.DefaultModelsExpandDepth(-1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
app.UseAuditing();
|
|
|
|
|
app.UseAbpSerilogEnrichers();
|
|
|
|
|
app.UseUnitOfWork();
|
|
|
|
|
app.UseConfiguredEndpoints(endpoints =>
|
|
|
|
|
{
|
2025-07-25 17:27:21 +08:00
|
|
|
endpoints.MapHealthChecks("/health");
|
|
|
|
|
|
2025-05-27 14:02:24 +08:00
|
|
|
// endpoints.MapHangfireDashboard("/hangfire", new DashboardOptions()
|
|
|
|
|
// {
|
|
|
|
|
// Authorization = new[] { new CustomHangfireAuthorizeFilter() },
|
|
|
|
|
// IgnoreAntiforgeryToken = true
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (configuration.GetValue("Consul:Enabled", false))
|
|
|
|
|
{
|
|
|
|
|
app.UseConsul();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|