first commit
This commit is contained in:
@ -0,0 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Volo.Abp.AspNetCore.Mvc;
|
||||
|
||||
namespace KonSoft.Report.Controllers;
|
||||
|
||||
public class HomeController : AbpController
|
||||
{
|
||||
public ActionResult Index()
|
||||
{
|
||||
return Redirect("~/swagger");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>KonSoft.Report</RootNamespace>
|
||||
<PreserveCompilationReferences>true</PreserveCompilationReferences>
|
||||
<UserSecretsId>KonSoft.Report-4681b4fd-151f-4221-84a4-929d86723e4c</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.MultiTenancy" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Autofac" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Swashbuckle" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Account.Web.OpenIddict" Version="8.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite" Version="3.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KonSoft.Report.Application\KonSoft.Report.Application.csproj" />
|
||||
<ProjectReference Include="..\KonSoft.Report.EntityFrameworkCore\KonSoft.Report.EntityFrameworkCore.csproj" />
|
||||
<ProjectReference Include="..\KonSoft.Report.HttpApi\KonSoft.Report.HttpApi.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Logs\**" />
|
||||
<Content Remove="Logs\**" />
|
||||
<EmbeddedResource Remove="Logs\**" />
|
||||
<None Remove="Logs\**" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
56
microservices/KonSoft.Report.HttpApi.Host/Program.cs
Normal file
56
microservices/KonSoft.Report.HttpApi.Host/Program.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Serilog;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace KonSoft.Report;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public async static Task<int> Main(string[] args)
|
||||
{
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
#if DEBUG
|
||||
.MinimumLevel.Debug()
|
||||
#else
|
||||
.MinimumLevel.Information()
|
||||
#endif
|
||||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
|
||||
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
|
||||
.Enrich.FromLogContext()
|
||||
.WriteTo.Async(c => c.File("Logs/logs.txt"))
|
||||
.WriteTo.Async(c => c.Console())
|
||||
.CreateLogger();
|
||||
|
||||
try
|
||||
{
|
||||
Log.Information("Starting KonSoft.Report.HttpApi.Host.");
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Host.AddAppSettingsSecretsJson()
|
||||
.UseAutofac()
|
||||
.UseSerilog();
|
||||
await builder.AddApplicationAsync<ReportHttpApiHostModule>();
|
||||
var app = builder.Build();
|
||||
await app.InitializeApplicationAsync();
|
||||
await app.RunAsync();
|
||||
return 0;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (ex is HostAbortedException)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
Log.Fatal(ex, "Host terminated unexpectedly!");
|
||||
return 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Log.CloseAndFlush();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "https://localhost:44340",
|
||||
"sslPort": 44340
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"KonSoft.Report.HttpApi.Host": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:44340",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using KonSoft.Report.Localization;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Ui.Branding;
|
||||
|
||||
namespace KonSoft.Report;
|
||||
|
||||
[Dependency(ReplaceServices = true)]
|
||||
public class ReportBrandingProvider : DefaultBrandingProvider
|
||||
{
|
||||
private IStringLocalizer<ReportResource> _localizer;
|
||||
|
||||
public ReportBrandingProvider(IStringLocalizer<ReportResource> localizer)
|
||||
{
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
||||
public override string AppName => _localizer["AppName"];
|
||||
}
|
||||
@ -0,0 +1,224 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using KonSoft.Report.EntityFrameworkCore;
|
||||
using KonSoft.Report.MultiTenancy;
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite;
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonXLite.Bundling;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using OpenIddict.Validation.AspNetCore;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Account;
|
||||
using Volo.Abp.Account.Web;
|
||||
using Volo.Abp.AspNetCore.MultiTenancy;
|
||||
using Volo.Abp.AspNetCore.Mvc;
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
|
||||
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
|
||||
using Volo.Abp.AspNetCore.Serilog;
|
||||
using Volo.Abp.Autofac;
|
||||
using Volo.Abp.Localization;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.Security.Claims;
|
||||
using Volo.Abp.Swashbuckle;
|
||||
using Volo.Abp.UI.Navigation.Urls;
|
||||
using Volo.Abp.VirtualFileSystem;
|
||||
|
||||
namespace KonSoft.Report;
|
||||
|
||||
[DependsOn(
|
||||
typeof(ReportHttpApiModule),
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(AbpAspNetCoreMultiTenancyModule),
|
||||
typeof(ReportApplicationModule),
|
||||
typeof(ReportEntityFrameworkCoreModule),
|
||||
typeof(AbpAspNetCoreMvcUiLeptonXLiteThemeModule),
|
||||
typeof(AbpAccountWebOpenIddictModule),
|
||||
typeof(AbpAspNetCoreSerilogModule),
|
||||
typeof(AbpSwashbuckleModule)
|
||||
)]
|
||||
public class ReportHttpApiHostModule : AbpModule
|
||||
{
|
||||
public override void PreConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
PreConfigure<OpenIddictBuilder>(builder =>
|
||||
{
|
||||
builder.AddValidation(options =>
|
||||
{
|
||||
options.AddAudiences("Report");
|
||||
options.UseLocalServer();
|
||||
options.UseAspNetCore();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
var configuration = context.Services.GetConfiguration();
|
||||
var hostingEnvironment = context.Services.GetHostingEnvironment();
|
||||
|
||||
ConfigureAuthentication(context);
|
||||
ConfigureBundles();
|
||||
ConfigureUrls(configuration);
|
||||
ConfigureConventionalControllers();
|
||||
ConfigureVirtualFileSystem(context);
|
||||
ConfigureCors(context, configuration);
|
||||
ConfigureSwaggerServices(context, configuration);
|
||||
}
|
||||
|
||||
private void ConfigureAuthentication(ServiceConfigurationContext context)
|
||||
{
|
||||
context.Services.ForwardIdentityAuthenticationForBearer(OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme);
|
||||
context.Services.Configure<AbpClaimsPrincipalFactoryOptions>(options =>
|
||||
{
|
||||
options.IsDynamicClaimsEnabled = true;
|
||||
});
|
||||
}
|
||||
|
||||
private void ConfigureBundles()
|
||||
{
|
||||
Configure<AbpBundlingOptions>(options =>
|
||||
{
|
||||
options.StyleBundles.Configure(
|
||||
LeptonXLiteThemeBundles.Styles.Global,
|
||||
bundle =>
|
||||
{
|
||||
bundle.AddFiles("/global-styles.css");
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
private void ConfigureUrls(IConfiguration configuration)
|
||||
{
|
||||
Configure<AppUrlOptions>(options =>
|
||||
{
|
||||
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
|
||||
options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"]?.Split(',') ?? Array.Empty<string>());
|
||||
|
||||
options.Applications["Angular"].RootUrl = configuration["App:ClientUrl"];
|
||||
options.Applications["Angular"].Urls[AccountUrlNames.PasswordReset] = "account/reset-password";
|
||||
});
|
||||
}
|
||||
|
||||
private void ConfigureVirtualFileSystem(ServiceConfigurationContext context)
|
||||
{
|
||||
var hostingEnvironment = context.Services.GetHostingEnvironment();
|
||||
|
||||
if (hostingEnvironment.IsDevelopment())
|
||||
{
|
||||
Configure<AbpVirtualFileSystemOptions>(options =>
|
||||
{
|
||||
options.FileSets.ReplaceEmbeddedByPhysical<ReportDomainSharedModule>(
|
||||
Path.Combine(hostingEnvironment.ContentRootPath,
|
||||
$"..{Path.DirectorySeparatorChar}KonSoft.Report.Domain.Shared"));
|
||||
options.FileSets.ReplaceEmbeddedByPhysical<ReportDomainModule>(
|
||||
Path.Combine(hostingEnvironment.ContentRootPath,
|
||||
$"..{Path.DirectorySeparatorChar}KonSoft.Report.Domain"));
|
||||
options.FileSets.ReplaceEmbeddedByPhysical<ReportApplicationContractsModule>(
|
||||
Path.Combine(hostingEnvironment.ContentRootPath,
|
||||
$"..{Path.DirectorySeparatorChar}KonSoft.Report.Application.Contracts"));
|
||||
options.FileSets.ReplaceEmbeddedByPhysical<ReportApplicationModule>(
|
||||
Path.Combine(hostingEnvironment.ContentRootPath,
|
||||
$"..{Path.DirectorySeparatorChar}KonSoft.Report.Application"));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void ConfigureConventionalControllers()
|
||||
{
|
||||
Configure<AbpAspNetCoreMvcOptions>(options =>
|
||||
{
|
||||
options.ConventionalControllers.Create(typeof(ReportApplicationModule).Assembly);
|
||||
});
|
||||
}
|
||||
|
||||
private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration)
|
||||
{
|
||||
context.Services.AddAbpSwaggerGenWithOAuth(
|
||||
configuration["AuthServer:Authority"]!,
|
||||
new Dictionary<string, string>
|
||||
{
|
||||
{"Report", "Report API"}
|
||||
},
|
||||
options =>
|
||||
{
|
||||
options.SwaggerDoc("v1", new OpenApiInfo { Title = "Report API", Version = "v1" });
|
||||
options.DocInclusionPredicate((docName, description) => true);
|
||||
options.CustomSchemaIds(type => type.FullName);
|
||||
});
|
||||
}
|
||||
|
||||
private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration)
|
||||
{
|
||||
context.Services.AddCors(options =>
|
||||
{
|
||||
options.AddDefaultPolicy(builder =>
|
||||
{
|
||||
builder
|
||||
.WithOrigins(configuration["App:CorsOrigins"]?
|
||||
.Split(",", StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(o => o.RemovePostFix("/"))
|
||||
.ToArray() ?? Array.Empty<string>())
|
||||
.WithAbpExposedHeaders()
|
||||
.SetIsOriginAllowedToAllowWildcardSubdomains()
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod()
|
||||
.AllowCredentials();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
||||
{
|
||||
var app = context.GetApplicationBuilder();
|
||||
var env = context.GetEnvironment();
|
||||
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseAbpRequestLocalization();
|
||||
|
||||
if (!env.IsDevelopment())
|
||||
{
|
||||
app.UseErrorPage();
|
||||
}
|
||||
|
||||
app.UseCorrelationId();
|
||||
app.UseStaticFiles();
|
||||
app.UseRouting();
|
||||
app.UseCors();
|
||||
app.UseAuthentication();
|
||||
app.UseAbpOpenIddictValidation();
|
||||
|
||||
if (MultiTenancyConsts.IsEnabled)
|
||||
{
|
||||
app.UseMultiTenancy();
|
||||
}
|
||||
app.UseUnitOfWork();
|
||||
app.UseDynamicClaims();
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseAbpSwaggerUI(c =>
|
||||
{
|
||||
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Report API");
|
||||
|
||||
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
|
||||
c.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
|
||||
c.OAuthScopes("Report");
|
||||
});
|
||||
|
||||
app.UseAuditing();
|
||||
app.UseAbpSerilogEnrichers();
|
||||
app.UseConfiguredEndpoints();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
module.exports = {
|
||||
aliases: {
|
||||
|
||||
},
|
||||
clean: [
|
||||
|
||||
],
|
||||
mappings: {
|
||||
|
||||
}
|
||||
};
|
||||
@ -0,0 +1,2 @@
|
||||
{
|
||||
}
|
||||
18
microservices/KonSoft.Report.HttpApi.Host/appsettings.json
Normal file
18
microservices/KonSoft.Report.HttpApi.Host/appsettings.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"App": {
|
||||
"SelfUrl": "https://localhost:44340",
|
||||
"CorsOrigins": "https://*.Report.com",
|
||||
"RedirectAllowedUrls": ""
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"Default": "Host=localhost;Port=5432;Database=Report;User ID=root;Password=myPassword;"
|
||||
},
|
||||
"AuthServer": {
|
||||
"Authority": "https://localhost:44340",
|
||||
"RequireHttpsMetadata": false,
|
||||
"SwaggerClientId": "Report_Swagger"
|
||||
},
|
||||
"StringEncryption": {
|
||||
"DefaultPassPhrase": "aRnRGh9BVWKdfQXb"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
{
|
||||
}
|
||||
8
microservices/KonSoft.Report.HttpApi.Host/package.json
Normal file
8
microservices/KonSoft.Report.HttpApi.Host/package.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"name": "my-app",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@abp/aspnetcore.mvc.ui.theme.leptonxlite": "~3.3.4"
|
||||
}
|
||||
}
|
||||
18
microservices/KonSoft.Report.HttpApi.Host/web.config
Normal file
18
microservices/KonSoft.Report.HttpApi.Host/web.config
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<location path="." inheritInChildApplications="false">
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
|
||||
</handlers>
|
||||
<aspNetCore processPath="dotnet" arguments=".\KonSoft.Report.HttpApi.Host.dll" stdoutLogEnabled="false" stdoutLogFile=".\Logs\stdout" hostingModel="inprocess" />
|
||||
</system.webServer>
|
||||
</location>
|
||||
<system.webServer>
|
||||
<httpProtocol>
|
||||
<customHeaders>
|
||||
<remove name="x-powered-by" />
|
||||
</customHeaders>
|
||||
</httpProtocol>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
@ -0,0 +1,6 @@
|
||||
/* Your Global Styles */
|
||||
|
||||
:root .lpx-brand-logo {
|
||||
--lpx-logo: url('/images/logo/leptonx/logo-light.png');
|
||||
--lpx-logo-icon: url('/images/logo/leptonx/logo-light-thumbnail.png');
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 9.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
Reference in New Issue
Block a user