2 changed files with 422 additions and 411 deletions
@ -1,32 +1,32 @@ |
|||||
using LINGYUN.Platform.Routes; |
using LINGYUN.Platform.Routes; |
||||
using System; |
using System; |
||||
using System.Collections.Generic; |
using System.Collections.Generic; |
||||
|
|
||||
namespace LINGYUN.Platform.Menus |
namespace LINGYUN.Platform.Menus |
||||
{ |
{ |
||||
public class MenuDto : RouteDto |
public class MenuDto : RouteDto |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// 菜单编号
|
/// 菜单编号
|
||||
/// </summary>
|
/// </summary>
|
||||
public string Code { get; set; } |
public string Code { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 菜单布局页
|
/// 菜单布局页
|
||||
/// </summary>
|
/// </summary>
|
||||
public string Component { get; set; } |
public string Component { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 所属平台
|
/// 所属平台
|
||||
/// </summary>
|
/// </summary>
|
||||
public PlatformType PlatformType { get; set; } |
public PlatformType PlatformType { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 父节点
|
/// 父节点
|
||||
/// </summary>
|
/// </summary>
|
||||
public Guid? ParentId { get; set; } |
public Guid? ParentId { get; set; } |
||||
/// <summary>
|
/// <summary>
|
||||
/// 所属布局标识
|
/// 所属布局标识
|
||||
/// </summary>
|
/// </summary>
|
||||
public Guid LayoutId { get; set; } |
public Guid LayoutId { get; set; } |
||||
|
|
||||
public bool IsPublic { get; set; } |
public bool IsPublic { get; set; } |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,379 +1,390 @@ |
|||||
using DotNetCore.CAP; |
using DotNetCore.CAP; |
||||
using LINGYUN.Abp.Aliyun.SettingManagement; |
using LINGYUN.Abp.Aliyun.SettingManagement; |
||||
using LINGYUN.Abp.AspNetCore.HttpOverrides; |
using LINGYUN.Abp.AspNetCore.HttpOverrides; |
||||
using LINGYUN.Abp.Auditing; |
using LINGYUN.Abp.Auditing; |
||||
using LINGYUN.Abp.EventBus.CAP; |
using LINGYUN.Abp.EventBus.CAP; |
||||
using LINGYUN.Abp.ExceptionHandling; |
using LINGYUN.Abp.ExceptionHandling; |
||||
using LINGYUN.Abp.ExceptionHandling.Emailing; |
using LINGYUN.Abp.ExceptionHandling.Emailing; |
||||
using LINGYUN.Abp.FeatureManagement; |
using LINGYUN.Abp.FeatureManagement; |
||||
using LINGYUN.Abp.LocalizationManagement; |
using LINGYUN.Abp.LocalizationManagement; |
||||
using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; |
using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; |
||||
using LINGYUN.Abp.MessageService; |
using LINGYUN.Abp.MessageService; |
||||
using LINGYUN.Abp.MultiTenancy.DbFinder; |
using LINGYUN.Abp.MultiTenancy.DbFinder; |
||||
using LINGYUN.Abp.OssManagement; |
using LINGYUN.Abp.OssManagement; |
||||
using LINGYUN.Abp.PermissionManagement.Identity; |
using LINGYUN.Abp.PermissionManagement.Identity; |
||||
using LINGYUN.Abp.SettingManagement; |
using LINGYUN.Abp.SettingManagement; |
||||
using LINGYUN.Abp.Sms.Aliyun; |
using LINGYUN.Abp.Sms.Aliyun; |
||||
using LINGYUN.Abp.TenantManagement; |
using LINGYUN.Abp.TenantManagement; |
||||
using LINGYUN.Abp.WeChat.SettingManagement; |
using LINGYUN.Abp.WeChat.SettingManagement; |
||||
using LINGYUN.ApiGateway; |
using LINGYUN.ApiGateway; |
||||
using LINGYUN.Platform; |
using LINGYUN.Platform; |
||||
using Microsoft.AspNetCore.Authentication.JwtBearer; |
using Microsoft.AspNetCore.Authentication.JwtBearer; |
||||
using Microsoft.AspNetCore.Builder; |
using Microsoft.AspNetCore.Builder; |
||||
using Microsoft.AspNetCore.DataProtection; |
using Microsoft.AspNetCore.DataProtection; |
||||
using Microsoft.AspNetCore.Hosting; |
using Microsoft.AspNetCore.Hosting; |
||||
using Microsoft.Extensions.Caching.StackExchangeRedis; |
using Microsoft.Extensions.Caching.StackExchangeRedis; |
||||
using Microsoft.Extensions.Configuration; |
using Microsoft.Extensions.Configuration; |
||||
using Microsoft.Extensions.DependencyInjection; |
using Microsoft.Extensions.DependencyInjection; |
||||
using Microsoft.Extensions.Hosting; |
using Microsoft.Extensions.Hosting; |
||||
using Microsoft.OpenApi.Models; |
using Microsoft.OpenApi.Models; |
||||
using StackExchange.Redis; |
using StackExchange.Redis; |
||||
using System; |
using System; |
||||
using System.Text; |
using System.Text; |
||||
using System.Text.Encodings.Web; |
using System.Text.Encodings.Web; |
||||
using System.Text.Unicode; |
using System.Text.Unicode; |
||||
using Volo.Abp; |
using Volo.Abp; |
||||
using Volo.Abp.AspNetCore.Authentication.JwtBearer; |
using Volo.Abp.AspNetCore.Authentication.JwtBearer; |
||||
using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; |
using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; |
||||
using Volo.Abp.AspNetCore.Security.Claims; |
using Volo.Abp.AspNetCore.Security.Claims; |
||||
using Volo.Abp.Auditing; |
using Volo.Abp.Auditing; |
||||
using Volo.Abp.AuditLogging.EntityFrameworkCore; |
using Volo.Abp.AuditLogging.EntityFrameworkCore; |
||||
using Volo.Abp.Authorization.Permissions; |
using Volo.Abp.Authorization.Permissions; |
||||
using Volo.Abp.Autofac; |
using Volo.Abp.Autofac; |
||||
using Volo.Abp.Caching; |
using Volo.Abp.Caching; |
||||
using Volo.Abp.Caching.StackExchangeRedis; |
using Volo.Abp.Caching.StackExchangeRedis; |
||||
using Volo.Abp.Data; |
using Volo.Abp.Data; |
||||
using Volo.Abp.Domain.Entities.Events.Distributed; |
using Volo.Abp.Domain.Entities.Events.Distributed; |
||||
using Volo.Abp.EntityFrameworkCore; |
using Volo.Abp.EntityFrameworkCore; |
||||
using Volo.Abp.EntityFrameworkCore.MySQL; |
using Volo.Abp.EntityFrameworkCore.MySQL; |
||||
using Volo.Abp.FeatureManagement; |
using Volo.Abp.FeatureManagement; |
||||
using Volo.Abp.FeatureManagement.EntityFrameworkCore; |
using Volo.Abp.FeatureManagement.EntityFrameworkCore; |
||||
using Volo.Abp.Identity.EntityFrameworkCore; |
using Volo.Abp.Identity.EntityFrameworkCore; |
||||
using Volo.Abp.Identity.Localization; |
using Volo.Abp.Identity.Localization; |
||||
using Volo.Abp.IdentityServer.EntityFrameworkCore; |
using Volo.Abp.IdentityServer.EntityFrameworkCore; |
||||
using Volo.Abp.Json; |
using Volo.Abp.Json; |
||||
using Volo.Abp.Json.SystemTextJson; |
using Volo.Abp.Json.SystemTextJson; |
||||
using Volo.Abp.Localization; |
using Volo.Abp.Localization; |
||||
using Volo.Abp.Modularity; |
using Volo.Abp.Modularity; |
||||
using Volo.Abp.MultiTenancy; |
using Volo.Abp.MultiTenancy; |
||||
using Volo.Abp.PermissionManagement; |
using Volo.Abp.PermissionManagement; |
||||
using Volo.Abp.PermissionManagement.EntityFrameworkCore; |
using Volo.Abp.PermissionManagement.EntityFrameworkCore; |
||||
using Volo.Abp.PermissionManagement.HttpApi; |
using Volo.Abp.PermissionManagement.HttpApi; |
||||
using Volo.Abp.PermissionManagement.IdentityServer; |
using Volo.Abp.PermissionManagement.IdentityServer; |
||||
using Volo.Abp.Security.Claims; |
using Volo.Abp.Security.Claims; |
||||
using Volo.Abp.Security.Encryption; |
using Volo.Abp.Security.Encryption; |
||||
using Volo.Abp.SettingManagement.EntityFrameworkCore; |
using Volo.Abp.SettingManagement.EntityFrameworkCore; |
||||
using Volo.Abp.TenantManagement.EntityFrameworkCore; |
using Volo.Abp.TenantManagement.EntityFrameworkCore; |
||||
using Volo.Abp.Threading; |
using Volo.Abp.Threading; |
||||
using Volo.Abp.VirtualFileSystem; |
using Volo.Abp.VirtualFileSystem; |
||||
|
|
||||
namespace LINGYUN.Abp.BackendAdmin |
namespace LINGYUN.Abp.BackendAdmin |
||||
{ |
{ |
||||
[DependsOn( |
[DependsOn( |
||||
typeof(AbpAspNetCoreMvcUiMultiTenancyModule), |
typeof(AbpAspNetCoreMvcUiMultiTenancyModule), |
||||
typeof(PlatformApplicationContractModule), |
typeof(PlatformApplicationContractModule), |
||||
typeof(ApiGatewayApplicationContractsModule), |
typeof(ApiGatewayApplicationContractsModule), |
||||
typeof(AbpOssManagementApplicationContractsModule), |
typeof(AbpOssManagementApplicationContractsModule), |
||||
typeof(AbpMessageServiceApplicationContractsModule), |
typeof(AbpMessageServiceApplicationContractsModule), |
||||
typeof(AbpLocalizationManagementApplicationContractsModule), |
typeof(AbpLocalizationManagementApplicationContractsModule), |
||||
typeof(LINGYUN.Abp.Account.AbpAccountApplicationContractsModule),// 引用类似的包主要用于聚合权限管理和设置
|
typeof(LINGYUN.Abp.Account.AbpAccountApplicationContractsModule),// 引用类似的包主要用于聚合权限管理和设置
|
||||
typeof(LINGYUN.Abp.Identity.AbpIdentityApplicationContractsModule), |
typeof(LINGYUN.Abp.Identity.AbpIdentityApplicationContractsModule), |
||||
typeof(LINGYUN.Abp.IdentityServer.AbpIdentityServerApplicationContractsModule), |
typeof(LINGYUN.Abp.IdentityServer.AbpIdentityServerApplicationContractsModule), |
||||
typeof(AbpSettingManagementApplicationModule), |
typeof(AbpSettingManagementApplicationModule), |
||||
typeof(AbpSettingManagementHttpApiModule), |
typeof(AbpSettingManagementHttpApiModule), |
||||
typeof(AbpPermissionManagementApplicationModule), |
typeof(AbpPermissionManagementApplicationModule), |
||||
typeof(AbpPermissionManagementHttpApiModule), |
typeof(AbpPermissionManagementHttpApiModule), |
||||
typeof(AbpFeatureManagementApplicationModule), |
typeof(AbpFeatureManagementApplicationModule), |
||||
typeof(AbpFeatureManagementHttpApiModule), |
typeof(AbpFeatureManagementHttpApiModule), |
||||
typeof(AbpFeatureManagementClientModule), |
typeof(AbpFeatureManagementClientModule), |
||||
typeof(AbpAuditingApplicationModule), |
typeof(AbpAuditingApplicationModule), |
||||
typeof(AbpAuditingHttpApiModule), |
typeof(AbpAuditingHttpApiModule), |
||||
typeof(AbpTenantManagementApplicationModule), |
typeof(AbpTenantManagementApplicationModule), |
||||
typeof(AbpTenantManagementHttpApiModule), |
typeof(AbpTenantManagementHttpApiModule), |
||||
typeof(AbpWeChatSettingManagementModule),// 微信配置管理模块
|
typeof(AbpWeChatSettingManagementModule),// 微信配置管理模块
|
||||
typeof(AbpAliyunSettingManagementModule),// 阿里云配置管理模块
|
typeof(AbpAliyunSettingManagementModule),// 阿里云配置管理模块
|
||||
typeof(AbpEntityFrameworkCoreMySQLModule), |
typeof(AbpEntityFrameworkCoreMySQLModule), |
||||
typeof(AbpIdentityEntityFrameworkCoreModule),// 用户角色权限需要引用包
|
typeof(AbpIdentityEntityFrameworkCoreModule),// 用户角色权限需要引用包
|
||||
typeof(AbpIdentityServerEntityFrameworkCoreModule), // 客户端权限需要引用包
|
typeof(AbpIdentityServerEntityFrameworkCoreModule), // 客户端权限需要引用包
|
||||
typeof(AbpAuditLoggingEntityFrameworkCoreModule), |
typeof(AbpAuditLoggingEntityFrameworkCoreModule), |
||||
typeof(AbpTenantManagementEntityFrameworkCoreModule), |
typeof(AbpTenantManagementEntityFrameworkCoreModule), |
||||
typeof(AbpSettingManagementEntityFrameworkCoreModule), |
typeof(AbpSettingManagementEntityFrameworkCoreModule), |
||||
typeof(AbpPermissionManagementDomainIdentityModule), |
typeof(AbpPermissionManagementDomainIdentityModule), |
||||
typeof(AbpPermissionManagementDomainIdentityServerModule), |
typeof(AbpPermissionManagementDomainIdentityServerModule), |
||||
typeof(AbpPermissionManagementEntityFrameworkCoreModule), |
typeof(AbpPermissionManagementEntityFrameworkCoreModule), |
||||
typeof(AbpFeatureManagementEntityFrameworkCoreModule), |
typeof(AbpFeatureManagementEntityFrameworkCoreModule), |
||||
typeof(AbpLocalizationManagementEntityFrameworkCoreModule), |
typeof(AbpLocalizationManagementEntityFrameworkCoreModule), |
||||
typeof(AbpAspNetCoreAuthenticationJwtBearerModule), |
typeof(AbpAspNetCoreAuthenticationJwtBearerModule), |
||||
typeof(AbpEmailingExceptionHandlingModule), |
typeof(AbpEmailingExceptionHandlingModule), |
||||
typeof(AbpCAPEventBusModule), |
typeof(AbpCAPEventBusModule), |
||||
typeof(AbpAliyunSmsModule), |
typeof(AbpAliyunSmsModule), |
||||
typeof(AbpDbFinderMultiTenancyModule), |
typeof(AbpDbFinderMultiTenancyModule), |
||||
typeof(AbpCachingStackExchangeRedisModule), |
typeof(AbpCachingStackExchangeRedisModule), |
||||
typeof(AbpAspNetCoreHttpOverridesModule), |
typeof(AbpAspNetCoreHttpOverridesModule), |
||||
typeof(AbpAutofacModule) |
typeof(AbpAutofacModule) |
||||
)] |
)] |
||||
public class BackendAdminHostModule : AbpModule |
public class BackendAdminHostModule : AbpModule |
||||
{ |
{ |
||||
public override void PreConfigureServices(ServiceConfigurationContext context) |
public override void PreConfigureServices(ServiceConfigurationContext context) |
||||
{ |
{ |
||||
var configuration = context.Services.GetConfiguration(); |
var configuration = context.Services.GetConfiguration(); |
||||
|
|
||||
PreConfigure<CapOptions>(options => |
PreConfigure<CapOptions>(options => |
||||
{ |
{ |
||||
options |
options |
||||
.UseMySql(configuration.GetConnectionString("Default")) |
.UseMySql(configuration.GetConnectionString("Default")) |
||||
.UseRabbitMQ(rabbitMQOptions => |
.UseRabbitMQ(rabbitMQOptions => |
||||
{ |
{ |
||||
configuration.GetSection("CAP:RabbitMQ").Bind(rabbitMQOptions); |
configuration.GetSection("CAP:RabbitMQ").Bind(rabbitMQOptions); |
||||
}) |
}) |
||||
.UseDashboard(); |
.UseDashboard(); |
||||
}); |
}); |
||||
} |
} |
||||
|
|
||||
public override void ConfigureServices(ServiceConfigurationContext context) |
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
{ |
{ |
||||
var hostingEnvironment = context.Services.GetHostingEnvironment(); |
var hostingEnvironment = context.Services.GetHostingEnvironment(); |
||||
var configuration = hostingEnvironment.BuildConfiguration(); |
var configuration = hostingEnvironment.BuildConfiguration(); |
||||
|
|
||||
// 配置Ef
|
// 配置Ef
|
||||
Configure<AbpDbContextOptions>(options => |
Configure<AbpDbContextOptions>(options => |
||||
{ |
{ |
||||
options.UseMySQL(); |
options.UseMySQL(); |
||||
}); |
}); |
||||
|
|
||||
// 中文序列化的编码问题
|
// 中文序列化的编码问题
|
||||
Configure<AbpSystemTextJsonSerializerOptions>(options => |
Configure<AbpSystemTextJsonSerializerOptions>(options => |
||||
{ |
{ |
||||
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); |
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); |
||||
}); |
}); |
||||
|
|
||||
// 加解密
|
// 加解密
|
||||
Configure<AbpStringEncryptionOptions>(options => |
Configure<AbpStringEncryptionOptions>(options => |
||||
{ |
{ |
||||
var encryptionConfiguration = configuration.GetSection("Encryption"); |
var encryptionConfiguration = configuration.GetSection("Encryption"); |
||||
if (encryptionConfiguration.Exists()) |
if (encryptionConfiguration.Exists()) |
||||
{ |
{ |
||||
options.DefaultPassPhrase = encryptionConfiguration["PassPhrase"] ?? options.DefaultPassPhrase; |
options.DefaultPassPhrase = encryptionConfiguration["PassPhrase"] ?? options.DefaultPassPhrase; |
||||
options.DefaultSalt = encryptionConfiguration.GetSection("Salt").Exists() |
options.DefaultSalt = encryptionConfiguration.GetSection("Salt").Exists() |
||||
? Encoding.ASCII.GetBytes(encryptionConfiguration["Salt"]) |
? Encoding.ASCII.GetBytes(encryptionConfiguration["Salt"]) |
||||
: options.DefaultSalt; |
: options.DefaultSalt; |
||||
options.InitVectorBytes = encryptionConfiguration.GetSection("InitVector").Exists() |
options.InitVectorBytes = encryptionConfiguration.GetSection("InitVector").Exists() |
||||
? Encoding.ASCII.GetBytes(encryptionConfiguration["InitVector"]) |
? Encoding.ASCII.GetBytes(encryptionConfiguration["InitVector"]) |
||||
: options.InitVectorBytes; |
: options.InitVectorBytes; |
||||
} |
} |
||||
}); |
}); |
||||
|
|
||||
Configure<PermissionManagementOptions>(options => |
Configure<PermissionManagementOptions>(options => |
||||
{ |
{ |
||||
// Rename IdentityServer.Client.ManagePermissions
|
// Rename IdentityServer.Client.ManagePermissions
|
||||
// See https://github.com/abpframework/abp/blob/dev/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo/Abp/PermissionManagement/IdentityServer/AbpPermissionManagementDomainIdentityServerModule.cs
|
// See https://github.com/abpframework/abp/blob/dev/modules/identityserver/src/Volo.Abp.PermissionManagement.Domain.IdentityServer/Volo/Abp/PermissionManagement/IdentityServer/AbpPermissionManagementDomainIdentityServerModule.cs
|
||||
options.ProviderPolicies[ClientPermissionValueProvider.ProviderName] = |
options.ProviderPolicies[ClientPermissionValueProvider.ProviderName] = |
||||
LINGYUN.Abp.IdentityServer.AbpIdentityServerPermissions.Clients.ManagePermissions; |
LINGYUN.Abp.IdentityServer.AbpIdentityServerPermissions.Clients.ManagePermissions; |
||||
}); |
}); |
||||
|
|
||||
// 自定义需要处理的异常
|
// 自定义需要处理的异常
|
||||
Configure<AbpExceptionHandlingOptions>(options => |
Configure<AbpExceptionHandlingOptions>(options => |
||||
{ |
{ |
||||
// 加入需要处理的异常类型
|
// 加入需要处理的异常类型
|
||||
options.Handlers.Add<Volo.Abp.Data.AbpDbConcurrencyException>(); |
options.Handlers.Add<Volo.Abp.Data.AbpDbConcurrencyException>(); |
||||
options.Handlers.Add<AbpInitializationException>(); |
options.Handlers.Add<AbpInitializationException>(); |
||||
options.Handlers.Add<ObjectDisposedException>(); |
options.Handlers.Add<ObjectDisposedException>(); |
||||
options.Handlers.Add<StackOverflowException>(); |
options.Handlers.Add<StackOverflowException>(); |
||||
options.Handlers.Add<OutOfMemoryException>(); |
options.Handlers.Add<OutOfMemoryException>(); |
||||
options.Handlers.Add<System.Data.Common.DbException>(); |
options.Handlers.Add<System.Data.Common.DbException>(); |
||||
options.Handlers.Add<Microsoft.EntityFrameworkCore.DbUpdateException>(); |
options.Handlers.Add<Microsoft.EntityFrameworkCore.DbUpdateException>(); |
||||
options.Handlers.Add<System.Data.DBConcurrencyException>(); |
options.Handlers.Add<System.Data.DBConcurrencyException>(); |
||||
}); |
}); |
||||
// 自定义需要发送邮件通知的异常类型
|
// 自定义需要发送邮件通知的异常类型
|
||||
Configure<AbpEmailExceptionHandlingOptions>(options => |
Configure<AbpEmailExceptionHandlingOptions>(options => |
||||
{ |
{ |
||||
// 是否发送堆栈信息
|
// 是否发送堆栈信息
|
||||
options.SendStackTrace = true; |
options.SendStackTrace = true; |
||||
// 未指定异常接收者的默认接收邮件
|
// 未指定异常接收者的默认接收邮件
|
||||
// 请指定自己的邮件地址
|
// 请指定自己的邮件地址
|
||||
// options.DefaultReceiveEmail = "colin.in@foxmail.com";
|
// options.DefaultReceiveEmail = "colin.in@foxmail.com";
|
||||
}); |
}); |
||||
|
|
||||
|
|
||||
Configure<AbpDistributedCacheOptions>(options => |
Configure<AbpDistributedCacheOptions>(options => |
||||
{ |
{ |
||||
// 最好统一命名,不然某个缓存变动其他应用服务有例外发生
|
// 最好统一命名,不然某个缓存变动其他应用服务有例外发生
|
||||
options.KeyPrefix = "LINGYUN.Abp.Application"; |
options.KeyPrefix = "LINGYUN.Abp.Application"; |
||||
// 滑动过期30天
|
// 滑动过期30天
|
||||
options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); |
options.GlobalCacheEntryOptions.SlidingExpiration = TimeSpan.FromDays(30); |
||||
// 绝对过期60天
|
// 绝对过期60天
|
||||
options.GlobalCacheEntryOptions.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(60); |
options.GlobalCacheEntryOptions.AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(60); |
||||
}); |
}); |
||||
|
|
||||
Configure<AbpDistributedEntityEventOptions>(options => |
Configure<AbpDistributedEntityEventOptions>(options => |
||||
{ |
{ |
||||
options.AutoEventSelectors.AddNamespace("Volo.Abp.TenantManagement"); |
options.AutoEventSelectors.AddNamespace("Volo.Abp.TenantManagement"); |
||||
}); |
}); |
||||
|
|
||||
Configure<RedisCacheOptions>(options => |
Configure<RedisCacheOptions>(options => |
||||
{ |
{ |
||||
var redisConfig = ConfigurationOptions.Parse(options.Configuration); |
var redisConfig = ConfigurationOptions.Parse(options.Configuration); |
||||
options.ConfigurationOptions = redisConfig; |
options.ConfigurationOptions = redisConfig; |
||||
options.InstanceName = configuration["Redis:InstanceName"]; |
options.InstanceName = configuration["Redis:InstanceName"]; |
||||
}); |
}); |
||||
|
|
||||
Configure<AbpVirtualFileSystemOptions>(options => |
Configure<AbpVirtualFileSystemOptions>(options => |
||||
{ |
{ |
||||
options.FileSets.AddEmbedded<BackendAdminHostModule>("LINGYUN.Abp.BackendAdmin"); |
options.FileSets.AddEmbedded<BackendAdminHostModule>("LINGYUN.Abp.BackendAdmin"); |
||||
}); |
}); |
||||
|
|
||||
// 多租户
|
// 多租户
|
||||
Configure<AbpMultiTenancyOptions>(options => |
Configure<AbpMultiTenancyOptions>(options => |
||||
{ |
{ |
||||
options.IsEnabled = true; |
options.IsEnabled = true; |
||||
}); |
}); |
||||
|
|
||||
var tenantResolveCfg = configuration.GetSection("App:Domains"); |
var tenantResolveCfg = configuration.GetSection("App:Domains"); |
||||
if (tenantResolveCfg.Exists()) |
if (tenantResolveCfg.Exists()) |
||||
{ |
{ |
||||
Configure<AbpTenantResolveOptions>(options => |
Configure<AbpTenantResolveOptions>(options => |
||||
{ |
{ |
||||
var domains = tenantResolveCfg.Get<string[]>(); |
var domains = tenantResolveCfg.Get<string[]>(); |
||||
foreach (var domain in domains) |
foreach (var domain in domains) |
||||
{ |
{ |
||||
options.AddDomainTenantResolver(domain); |
options.AddDomainTenantResolver(domain); |
||||
} |
} |
||||
}); |
}); |
||||
} |
} |
||||
|
|
||||
Configure<AbpAuditingOptions>(options => |
Configure<AbpAuditingOptions>(options => |
||||
{ |
{ |
||||
options.ApplicationName = "Backend-Admin"; |
options.ApplicationName = "Backend-Admin"; |
||||
// 是否启用实体变更记录
|
// 是否启用实体变更记录
|
||||
var entitiesChangedConfig = configuration.GetSection("App:TrackingEntitiesChanged"); |
var entitiesChangedConfig = configuration.GetSection("App:TrackingEntitiesChanged"); |
||||
if (entitiesChangedConfig.Exists() && entitiesChangedConfig.Get<bool>()) |
if (entitiesChangedConfig.Exists() && entitiesChangedConfig.Get<bool>()) |
||||
{ |
{ |
||||
options |
options |
||||
.EntityHistorySelectors |
.EntityHistorySelectors |
||||
.AddAllEntities(); |
.AddAllEntities(); |
||||
} |
} |
||||
}); |
}); |
||||
|
|
||||
// Swagger
|
// Swagger
|
||||
context.Services.AddSwaggerGen( |
context.Services.AddSwaggerGen( |
||||
options => |
options => |
||||
{ |
{ |
||||
options.SwaggerDoc("v1", new OpenApiInfo { Title = "BackendAdmin API", Version = "v1" }); |
options.SwaggerDoc("v1", new OpenApiInfo { Title = "BackendAdmin API", Version = "v1" }); |
||||
options.DocInclusionPredicate((docName, description) => true); |
options.DocInclusionPredicate((docName, description) => true); |
||||
options.CustomSchemaIds(type => type.FullName); |
options.CustomSchemaIds(type => type.FullName); |
||||
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme |
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme |
||||
{ |
{ |
||||
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", |
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", |
||||
Name = "Authorization", |
Name = "Authorization", |
||||
In = ParameterLocation.Header, |
In = ParameterLocation.Header, |
||||
Scheme = "bearer", |
Scheme = "bearer", |
||||
Type = SecuritySchemeType.Http, |
Type = SecuritySchemeType.Http, |
||||
BearerFormat = "JWT" |
BearerFormat = "JWT" |
||||
}); |
}); |
||||
options.AddSecurityRequirement(new OpenApiSecurityRequirement |
options.AddSecurityRequirement(new OpenApiSecurityRequirement |
||||
{ |
{ |
||||
{ |
{ |
||||
new OpenApiSecurityScheme |
new OpenApiSecurityScheme |
||||
{ |
{ |
||||
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" } |
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" } |
||||
}, |
}, |
||||
new string[] { } |
new string[] { } |
||||
} |
} |
||||
}); |
}); |
||||
}); |
}); |
||||
|
|
||||
// 支持本地化语言类型
|
// 支持本地化语言类型
|
||||
Configure<AbpLocalizationOptions>(options => |
Configure<AbpLocalizationOptions>(options => |
||||
{ |
{ |
||||
options.Languages.Add(new LanguageInfo("en", "en", "English")); |
options.Languages.Add(new LanguageInfo("en", "en", "English")); |
||||
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); |
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); |
||||
|
|
||||
options.Resources |
options.Resources |
||||
.Get<IdentityResource>() |
.Get<IdentityResource>() |
||||
.AddVirtualJson("/Localization"); |
.AddVirtualJson("/Localization"); |
||||
options |
options |
||||
.AddLanguagesMapOrUpdate( |
.AddLanguagesMapOrUpdate( |
||||
"vue-admin-element-ui", |
"vue-admin-element-ui", |
||||
new NameValue("zh-Hans", "zh"), |
new NameValue("zh-Hans", "zh"), |
||||
new NameValue("en", "en")); |
new NameValue("en", "en")); |
||||
options |
|
||||
.AddLanguageFilesMapOrUpdate( |
// vben admin 语言映射
|
||||
"vue-admin-element-ui", |
options |
||||
new NameValue("zh-Hans", "zh"), |
.AddLanguagesMapOrUpdate( |
||||
new NameValue("en", "en")); |
"vben-admin-ui", |
||||
|
new NameValue("zh_CN", "zh-Hans")); |
||||
options.Resources.AddDynamic(); |
|
||||
}); |
options |
||||
|
.AddLanguageFilesMapOrUpdate( |
||||
Configure<AbpClaimsMapOptions>(options => |
"vue-admin-element-ui", |
||||
{ |
new NameValue("zh-Hans", "zh"), |
||||
options.Maps.TryAdd("name", () => AbpClaimTypes.UserName); |
new NameValue("en", "en")); |
||||
}); |
options |
||||
|
.AddLanguageFilesMapOrUpdate( |
||||
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) |
"vben-admin-ui", |
||||
.AddJwtBearer(options => |
new NameValue("zh_CN", "zh-Hans")); |
||||
{ |
|
||||
options.Authority = configuration["AuthServer:Authority"]; |
options.Resources.AddDynamic(); |
||||
options.RequireHttpsMetadata = false; |
}); |
||||
options.Audience = configuration["AuthServer:ApiName"]; |
|
||||
}); |
Configure<AbpClaimsMapOptions>(options => |
||||
|
{ |
||||
if (!hostingEnvironment.IsDevelopment()) |
options.Maps.TryAdd("name", () => AbpClaimTypes.UserName); |
||||
{ |
}); |
||||
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); |
|
||||
context.Services |
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) |
||||
.AddDataProtection() |
.AddJwtBearer(options => |
||||
.PersistKeysToStackExchangeRedis(redis, "BackendAdmin-Protection-Keys"); |
{ |
||||
} |
options.Authority = configuration["AuthServer:Authority"]; |
||||
} |
options.RequireHttpsMetadata = false; |
||||
|
options.Audience = configuration["AuthServer:ApiName"]; |
||||
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
}); |
||||
{ |
|
||||
var app = context.GetApplicationBuilder(); |
if (!hostingEnvironment.IsDevelopment()) |
||||
// http调用链
|
{ |
||||
app.UseCorrelationId(); |
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); |
||||
// 虚拟文件系统
|
context.Services |
||||
app.UseStaticFiles(); |
.AddDataProtection() |
||||
// 本地化
|
.PersistKeysToStackExchangeRedis(redis, "BackendAdmin-Protection-Keys"); |
||||
app.UseAbpRequestLocalization(); |
} |
||||
//路由
|
} |
||||
app.UseRouting(); |
|
||||
// 认证
|
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
||||
app.UseAuthentication(); |
{ |
||||
// jwt
|
var app = context.GetApplicationBuilder(); |
||||
app.UseJwtTokenMiddleware(); |
// http调用链
|
||||
// 多租户
|
app.UseCorrelationId(); |
||||
app.UseMultiTenancy(); |
// 虚拟文件系统
|
||||
// Swagger
|
app.UseStaticFiles(); |
||||
app.UseSwagger(); |
// 本地化
|
||||
// Swagger可视化界面
|
app.UseAbpRequestLocalization(); |
||||
app.UseSwaggerUI(options => |
//路由
|
||||
{ |
app.UseRouting(); |
||||
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support BackendAdmin API"); |
// 认证
|
||||
}); |
app.UseAuthentication(); |
||||
// 审计日志
|
// jwt
|
||||
app.UseAuditing(); |
app.UseJwtTokenMiddleware(); |
||||
// 处理微信消息
|
// 多租户
|
||||
// app.UseWeChatSignature();
|
app.UseMultiTenancy(); |
||||
// 路由
|
// Swagger
|
||||
app.UseConfiguredEndpoints(); |
app.UseSwagger(); |
||||
|
// Swagger可视化界面
|
||||
// 调试代理连接信息用,上线后注释掉
|
app.UseSwaggerUI(options => |
||||
app.UseProxyConnectTest(); |
{ |
||||
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support BackendAdmin API"); |
||||
if (context.GetEnvironment().IsDevelopment()) |
}); |
||||
{ |
// 审计日志
|
||||
SeedData(context); |
app.UseAuditing(); |
||||
} |
// 处理微信消息
|
||||
} |
// app.UseWeChatSignature();
|
||||
|
// 路由
|
||||
private void SeedData(ApplicationInitializationContext context) |
app.UseConfiguredEndpoints(); |
||||
{ |
|
||||
AsyncHelper.RunSync(async () => |
// 调试代理连接信息用,上线后注释掉
|
||||
{ |
app.UseProxyConnectTest(); |
||||
using var scope = context.ServiceProvider.CreateScope(); |
|
||||
await scope.ServiceProvider.GetRequiredService<IDataSeeder>().SeedAsync(); |
if (context.GetEnvironment().IsDevelopment()) |
||||
}); |
{ |
||||
} |
SeedData(context); |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
|
private void SeedData(ApplicationInitializationContext context) |
||||
|
{ |
||||
|
AsyncHelper.RunSync(async () => |
||||
|
{ |
||||
|
using var scope = context.ServiceProvider.CreateScope(); |
||||
|
await scope.ServiceProvider.GetRequiredService<IDataSeeder>().SeedAsync(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|||||
Loading…
Reference in new issue