mirror of https://github.com/abpframework/abp
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.
230 lines
9.8 KiB
230 lines
9.8 KiB
using System.IO;
|
|
using System.Linq;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Volo.CmsKit.EntityFrameworkCore;
|
|
using Volo.CmsKit.MultiTenancy;
|
|
using Volo.CmsKit.Web;
|
|
using Microsoft.OpenApi.Models;
|
|
using Volo.Abp;
|
|
using Volo.Abp.Account;
|
|
using Volo.Abp.Account.Web;
|
|
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
|
|
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
|
|
using Volo.Abp.AspNetCore.Serilog;
|
|
using Volo.Abp.AuditLogging.EntityFrameworkCore;
|
|
using Volo.Abp.Autofac;
|
|
using Volo.Abp.BlobStoring.Database.EntityFrameworkCore;
|
|
using Volo.Abp.Data;
|
|
using Volo.Abp.EntityFrameworkCore;
|
|
using Volo.Abp.EntityFrameworkCore.SqlServer;
|
|
using Volo.Abp.FeatureManagement.EntityFrameworkCore;
|
|
using Volo.Abp.FeatureManagement;
|
|
using Volo.Abp.Identity;
|
|
using Volo.Abp.Identity.EntityFrameworkCore;
|
|
using Volo.Abp.Identity.Web;
|
|
using Volo.Abp.Localization;
|
|
using Volo.Abp.Modularity;
|
|
using Volo.Abp.MultiTenancy;
|
|
using Volo.Abp.PermissionManagement;
|
|
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
|
|
using Volo.Abp.PermissionManagement.Identity;
|
|
using Volo.Abp.SettingManagement.EntityFrameworkCore;
|
|
using Volo.Abp.Swashbuckle;
|
|
using Volo.Abp.TenantManagement;
|
|
using Volo.Abp.TenantManagement.EntityFrameworkCore;
|
|
using Volo.Abp.TenantManagement.Web;
|
|
using Volo.Abp.Threading;
|
|
using Volo.Abp.VirtualFileSystem;
|
|
using Volo.CmsKit.Admin.Web;
|
|
using Volo.CmsKit.Public.Web;
|
|
using System;
|
|
using Volo.CmsKit.Tags;
|
|
using Volo.CmsKit.Comments;
|
|
using Volo.CmsKit.MediaDescriptors;
|
|
using Volo.CmsKit.Reactions;
|
|
using Volo.CmsKit.Ratings;
|
|
|
|
namespace Volo.CmsKit
|
|
{
|
|
[DependsOn(
|
|
typeof(CmsKitWebModule),
|
|
typeof(CmsKitApplicationModule),
|
|
typeof(CmsKitEntityFrameworkCoreModule),
|
|
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
|
|
typeof(AbpAutofacModule),
|
|
typeof(AbpAccountWebModule),
|
|
typeof(AbpAccountApplicationModule),
|
|
typeof(AbpEntityFrameworkCoreSqlServerModule),
|
|
typeof(AbpSettingManagementEntityFrameworkCoreModule),
|
|
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
|
|
typeof(AbpPermissionManagementApplicationModule),
|
|
typeof(AbpIdentityWebModule),
|
|
typeof(AbpIdentityApplicationModule),
|
|
typeof(AbpIdentityEntityFrameworkCoreModule),
|
|
typeof(AbpPermissionManagementDomainIdentityModule),
|
|
typeof(AbpFeatureManagementApplicationModule),
|
|
typeof(AbpFeatureManagementEntityFrameworkCoreModule),
|
|
typeof(AbpFeatureManagementWebModule),
|
|
typeof(AbpTenantManagementWebModule),
|
|
typeof(AbpTenantManagementApplicationModule),
|
|
typeof(AbpTenantManagementEntityFrameworkCoreModule),
|
|
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
|
|
typeof(AbpAspNetCoreSerilogModule),
|
|
typeof(BlobStoringDatabaseEntityFrameworkCoreModule),
|
|
typeof(AbpSwashbuckleModule)
|
|
)]
|
|
public class CmsKitWebUnifiedModule : AbpModule
|
|
{
|
|
public override void PreConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
FeatureConfigurer.Configure();
|
|
}
|
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
var hostingEnvironment = context.Services.GetHostingEnvironment();
|
|
var configuration = context.Services.GetConfiguration();
|
|
|
|
ConfigureCmsKit(context);
|
|
|
|
Configure<AbpDbContextOptions>(options =>
|
|
{
|
|
options.UseSqlServer();
|
|
});
|
|
|
|
if (hostingEnvironment.IsDevelopment())
|
|
{
|
|
Configure<AbpVirtualFileSystemOptions>(options =>
|
|
{
|
|
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiThemeSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}framework/src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar)));
|
|
|
|
options.FileSets.ReplaceEmbeddedByPhysical<CmsKitDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Domain.Shared", Path.DirectorySeparatorChar)));
|
|
options.FileSets.ReplaceEmbeddedByPhysical<CmsKitDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Domain", Path.DirectorySeparatorChar)));
|
|
|
|
options.FileSets.ReplaceEmbeddedByPhysical<CmsKitCommonWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Common.Web", Path.DirectorySeparatorChar)));
|
|
options.FileSets.ReplaceEmbeddedByPhysical<CmsKitPublicWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Public.Web", Path.DirectorySeparatorChar)));
|
|
options.FileSets.ReplaceEmbeddedByPhysical<CmsKitAdminWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Admin.Web", Path.DirectorySeparatorChar)));
|
|
|
|
options.FileSets.ReplaceEmbeddedByPhysical<CmsKitApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Application.Contracts", Path.DirectorySeparatorChar)));
|
|
options.FileSets.ReplaceEmbeddedByPhysical<CmsKitApplicationModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Application", Path.DirectorySeparatorChar)));
|
|
options.FileSets.ReplaceEmbeddedByPhysical<CmsKitWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Web", Path.DirectorySeparatorChar)));
|
|
});
|
|
}
|
|
|
|
context.Services.AddSwaggerGen(
|
|
options =>
|
|
{
|
|
options.SwaggerDoc("v1", new OpenApiInfo { Title = "CmsKit API", Version = "v1" });
|
|
options.DocInclusionPredicate((docName, description) => true);
|
|
options.CustomSchemaIds(type => type.FullName);
|
|
});
|
|
|
|
Configure<AbpLocalizationOptions>(options =>
|
|
{
|
|
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
|
|
options.Languages.Add(new LanguageInfo("en", "en", "English"));
|
|
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
|
|
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
|
|
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
|
|
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
|
|
options.Languages.Add(new LanguageInfo("it", "it", "Italian", "it"));
|
|
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português (Brasil)"));
|
|
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
|
|
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
|
|
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
|
|
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
|
|
});
|
|
|
|
Configure<AbpMultiTenancyOptions>(options =>
|
|
{
|
|
options.IsEnabled = MultiTenancyConsts.IsEnabled;
|
|
});
|
|
}
|
|
|
|
private void ConfigureCmsKit(ServiceConfigurationContext context)
|
|
{
|
|
Configure<CmsKitTagOptions>(options =>
|
|
{
|
|
options.EntityTypes.Add(new TagEntityTypeDefiniton("quote"));
|
|
});
|
|
|
|
Configure<CmsKitCommentOptions>(options =>
|
|
{
|
|
options.EntityTypes.Add(new CommentEntityTypeDefinition("quote"));
|
|
});
|
|
|
|
Configure<CmsKitMediaOptions>(options =>
|
|
{
|
|
options.EntityTypes.Add(new MediaDescriptorDefinition("quote"));
|
|
});
|
|
|
|
Configure<CmsKitReactionOptions>(options =>
|
|
{
|
|
options.EntityTypes.Add(
|
|
new ReactionEntityTypeDefinition("quote",
|
|
reactions: new[]
|
|
{
|
|
new ReactionDefinition(StandardReactions.ThumbsUp),
|
|
new ReactionDefinition(StandardReactions.ThumbsDown),
|
|
}));
|
|
});
|
|
|
|
Configure<CmsKitRatingOptions>(options =>
|
|
{
|
|
options.EntityTypes.Add(new RatingEntityTypeDefinition("quote"));
|
|
});
|
|
}
|
|
|
|
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
|
{
|
|
var app = context.GetApplicationBuilder();
|
|
var env = context.GetEnvironment();
|
|
|
|
if (env.IsDevelopment())
|
|
{
|
|
app.UseDeveloperExceptionPage();
|
|
}
|
|
else
|
|
{
|
|
app.UseErrorPage();
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
app.UseStaticFiles();
|
|
app.UseRouting();
|
|
app.UseAuthentication();
|
|
|
|
if (MultiTenancyConsts.IsEnabled)
|
|
{
|
|
app.UseMultiTenancy();
|
|
}
|
|
|
|
app.UseAbpRequestLocalization();
|
|
app.UseAuthorization();
|
|
|
|
app.UseSwagger();
|
|
app.UseAbpSwaggerUI(options =>
|
|
{
|
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API");
|
|
});
|
|
|
|
app.UseAuditing();
|
|
app.UseAbpSerilogEnrichers();
|
|
app.UseConfiguredEndpoints();
|
|
|
|
using (var scope = context.ServiceProvider.CreateScope())
|
|
{
|
|
AsyncHelper.RunSync(async () =>
|
|
{
|
|
await scope.ServiceProvider
|
|
.GetRequiredService<IDataSeeder>()
|
|
.SeedAsync();
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|