56 changed files with 1027 additions and 604 deletions
@ -1,11 +0,0 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace Lion.AbpPro.FileManagement.Samples; |
|||
|
|||
public interface ISampleAppService : IApplicationService |
|||
{ |
|||
Task<SampleDto> GetAsync(); |
|||
|
|||
Task<SampleDto> GetAuthorizedAsync(); |
|||
} |
|||
@ -1,6 +0,0 @@ |
|||
namespace Lion.AbpPro.FileManagement.Samples; |
|||
|
|||
public class SampleDto |
|||
{ |
|||
public int Value { get; set; } |
|||
} |
|||
@ -1,28 +0,0 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
|
|||
namespace Lion.AbpPro.FileManagement.Samples; |
|||
|
|||
public class SampleAppService : FileManagementAppService, ISampleAppService |
|||
{ |
|||
public Task<SampleDto> GetAsync() |
|||
{ |
|||
return Task.FromResult( |
|||
new SampleDto |
|||
{ |
|||
Value = 42 |
|||
} |
|||
); |
|||
} |
|||
|
|||
[Authorize] |
|||
public Task<SampleDto> GetAuthorizedAsync() |
|||
{ |
|||
return Task.FromResult( |
|||
new SampleDto |
|||
{ |
|||
Value = 42 |
|||
} |
|||
); |
|||
} |
|||
} |
|||
@ -1,33 +0,0 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp; |
|||
|
|||
namespace Lion.AbpPro.FileManagement.Samples; |
|||
|
|||
[Area(FileManagementRemoteServiceConsts.ModuleName)] |
|||
[RemoteService(Name = FileManagementRemoteServiceConsts.RemoteServiceName)] |
|||
[Route("api/FileManagement/sample")] |
|||
public class SampleController : FileManagementController, ISampleAppService |
|||
{ |
|||
private readonly ISampleAppService _sampleAppService; |
|||
|
|||
public SampleController(ISampleAppService sampleAppService) |
|||
{ |
|||
_sampleAppService = sampleAppService; |
|||
} |
|||
|
|||
[HttpGet] |
|||
public async Task<SampleDto> GetAsync() |
|||
{ |
|||
return await _sampleAppService.GetAsync(); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("authorized")] |
|||
[Authorize] |
|||
public async Task<SampleDto> GetAuthorizedAsync() |
|||
{ |
|||
return await _sampleAppService.GetAsync(); |
|||
} |
|||
} |
|||
@ -1,29 +0,0 @@ |
|||
using System.Threading.Tasks; |
|||
using Shouldly; |
|||
using Xunit; |
|||
|
|||
namespace Lion.AbpPro.FileManagement.Samples; |
|||
|
|||
public class SampleAppService_Tests : FileManagementApplicationTestBase |
|||
{ |
|||
private readonly ISampleAppService _sampleAppService; |
|||
|
|||
public SampleAppService_Tests() |
|||
{ |
|||
_sampleAppService = GetRequiredService<ISampleAppService>(); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task GetAsync() |
|||
{ |
|||
var result = await _sampleAppService.GetAsync(); |
|||
result.Value.ShouldBe(42); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task GetAuthorizedAsync() |
|||
{ |
|||
var result = await _sampleAppService.GetAuthorizedAsync(); |
|||
result.Value.ShouldBe(42); |
|||
} |
|||
} |
|||
@ -1,156 +0,0 @@ |
|||
using System; |
|||
using System.Net.Http; |
|||
using System.Threading.Tasks; |
|||
using IdentityModel.Client; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Lion.AbpPro.FileManagement.Samples; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.IdentityModel; |
|||
|
|||
namespace Lion.AbpPro.FileManagement |
|||
{ |
|||
public class ClientDemoService : ITransientDependency |
|||
{ |
|||
private readonly ISampleAppService _sampleAppService; |
|||
private readonly IIdentityModelAuthenticationService _authenticationService; |
|||
private readonly IConfiguration _configuration; |
|||
|
|||
public ClientDemoService( |
|||
ISampleAppService sampleAppService, |
|||
IIdentityModelAuthenticationService authenticationService, |
|||
IConfiguration configuration) |
|||
{ |
|||
_sampleAppService = sampleAppService; |
|||
_authenticationService = authenticationService; |
|||
_configuration = configuration; |
|||
} |
|||
|
|||
public async Task RunAsync() |
|||
{ |
|||
await TestWithDynamicProxiesAsync(); |
|||
await TestWithHttpClientAndIdentityModelAuthenticationServiceAsync(); |
|||
await TestAllManuallyAsync(); |
|||
} |
|||
|
|||
/* Shows how to perform an HTTP request to the API using ABP's dynamic c# proxy |
|||
* feature. It is just simple as calling a local service method. |
|||
* Authorization and HTTP request details are handled by the ABP framework. |
|||
*/ |
|||
private async Task TestWithDynamicProxiesAsync() |
|||
{ |
|||
Console.WriteLine(); |
|||
Console.WriteLine($"***** {nameof(TestWithDynamicProxiesAsync)} *****"); |
|||
|
|||
var result = await _sampleAppService.GetAsync(); |
|||
Console.WriteLine("Result: " + result.Value); |
|||
|
|||
result = await _sampleAppService.GetAuthorizedAsync(); |
|||
Console.WriteLine("Result (authorized): " + result.Value); |
|||
} |
|||
|
|||
/* Shows how to use HttpClient to perform a request to the HTTP API. |
|||
* It uses ABP's IIdentityModelAuthenticationService to simplify obtaining access tokens. |
|||
*/ |
|||
private async Task TestWithHttpClientAndIdentityModelAuthenticationServiceAsync() |
|||
{ |
|||
Console.WriteLine(); |
|||
Console.WriteLine($"***** {nameof(TestWithHttpClientAndIdentityModelAuthenticationServiceAsync)} *****"); |
|||
|
|||
//Get access token using ABP's IIdentityModelAuthenticationService
|
|||
|
|||
var accessToken = await _authenticationService.GetAccessTokenAsync( |
|||
new IdentityClientConfiguration( |
|||
_configuration["IdentityClients:Default:Authority"], |
|||
_configuration["IdentityClients:Default:Scope"], |
|||
_configuration["IdentityClients:Default:ClientId"], |
|||
_configuration["IdentityClients:Default:ClientSecret"], |
|||
_configuration["IdentityClients:Default:GrantType"], |
|||
_configuration["IdentityClients:Default:UserName"], |
|||
_configuration["IdentityClients:Default:UserPassword"] |
|||
) |
|||
); |
|||
|
|||
//Perform the actual HTTP request
|
|||
|
|||
using (var httpClient = new HttpClient()) |
|||
{ |
|||
httpClient.SetBearerToken(accessToken); |
|||
|
|||
var url = _configuration["RemoteServices:FileManagement:BaseUrl"] + |
|||
"api/FileManagement/sample/authorized"; |
|||
|
|||
var responseMessage = await httpClient.GetAsync(url); |
|||
if (responseMessage.IsSuccessStatusCode) |
|||
{ |
|||
var responseString = await responseMessage.Content.ReadAsStringAsync(); |
|||
Console.WriteLine("Result: " + responseString); |
|||
} |
|||
else |
|||
{ |
|||
throw new Exception("Remote server returns error code: " + responseMessage.StatusCode); |
|||
} |
|||
} |
|||
} |
|||
|
|||
/* Shows how to use HttpClient to perform a request to the HTTP API. |
|||
* It obtains access token using IdentityServer's API. See its documentation: |
|||
* https://identityserver4.readthedocs.io/en/latest/quickstarts/2_resource_owner_passwords.html
|
|||
*/ |
|||
private async Task TestAllManuallyAsync() |
|||
{ |
|||
Console.WriteLine(); |
|||
Console.WriteLine($"***** {nameof(TestAllManuallyAsync)} *****"); |
|||
|
|||
//Obtain access token from the IDS4 server
|
|||
|
|||
// discover endpoints from metadata
|
|||
var client = new HttpClient(); |
|||
var disco = await client.GetDiscoveryDocumentAsync(_configuration["IdentityClients:Default:Authority"]); |
|||
if (disco.IsError) |
|||
{ |
|||
Console.WriteLine(disco.Error); |
|||
return; |
|||
} |
|||
|
|||
// request token
|
|||
var tokenResponse = await client.RequestPasswordTokenAsync(new PasswordTokenRequest |
|||
{ |
|||
Address = disco.TokenEndpoint, |
|||
ClientId = _configuration["IdentityClients:Default:ClientId"], |
|||
ClientSecret = _configuration["IdentityClients:Default:ClientSecret"], |
|||
UserName = _configuration["IdentityClients:Default:UserName"], |
|||
Password = _configuration["IdentityClients:Default:UserPassword"], |
|||
Scope = _configuration["IdentityClients:Default:Scope"] |
|||
}); |
|||
|
|||
if (tokenResponse.IsError) |
|||
{ |
|||
Console.WriteLine(tokenResponse.Error); |
|||
return; |
|||
} |
|||
|
|||
Console.WriteLine(tokenResponse.Json); |
|||
|
|||
//Perform the actual HTTP request
|
|||
|
|||
using (var httpClient = new HttpClient()) |
|||
{ |
|||
httpClient.SetBearerToken(tokenResponse.AccessToken); |
|||
|
|||
var url = _configuration["RemoteServices:FileManagement:BaseUrl"] + |
|||
"api/FileManagement/sample/authorized"; |
|||
|
|||
var responseMessage = await httpClient.GetAsync(url); |
|||
if (responseMessage.IsSuccessStatusCode) |
|||
{ |
|||
var responseString = await responseMessage.Content.ReadAsStringAsync(); |
|||
Console.WriteLine("Result: " + responseString); |
|||
} |
|||
else |
|||
{ |
|||
throw new Exception("Remote server returns error code: " + responseMessage.StatusCode); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,38 +0,0 @@ |
|||
using Microsoft.Extensions.Hosting; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp; |
|||
|
|||
namespace Lion.AbpPro.FileManagement.HttpApi.Client.ConsoleTestApp |
|||
{ |
|||
public class ConsoleTestAppHostedService : IHostedService |
|||
{ |
|||
private readonly IConfiguration _configuration; |
|||
|
|||
public ConsoleTestAppHostedService(IConfiguration configuration) |
|||
{ |
|||
_configuration = configuration; |
|||
} |
|||
|
|||
public async Task StartAsync(CancellationToken cancellationToken) |
|||
{ |
|||
using (var application = AbpApplicationFactory.Create<FileManagementConsoleApiClientModule>(options=> |
|||
{ |
|||
options.Services.ReplaceConfiguration(_configuration); |
|||
options.UseAutofac(); |
|||
})) |
|||
{ |
|||
application.Initialize(); |
|||
|
|||
var demo = application.ServiceProvider.GetRequiredService<ClientDemoService>(); |
|||
await demo.RunAsync(); |
|||
|
|||
application.Shutdown(); |
|||
} |
|||
} |
|||
|
|||
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; |
|||
} |
|||
} |
|||
@ -1,16 +0,0 @@ |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.Http.Client.IdentityModel; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Lion.AbpPro.FileManagement |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpAutofacModule), |
|||
typeof(FileManagementHttpApiClientModule), |
|||
typeof(AbpHttpClientIdentityModelModule) |
|||
)] |
|||
public class FileManagementConsoleApiClientModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -1 +0,0 @@ |
|||
{} |
|||
@ -1,32 +0,0 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
<RootNamespace>Lion.AbpPro.FileManagement</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Http.Client.IdentityModel" Version="$(AbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.Autofac" Version="$(AbpPackageVersion)" /> |
|||
<ProjectReference Include="..\..\src\Lion.AbpPro.FileManagement.HttpApi.Client\Lion.AbpPro.FileManagement.HttpApi.Client.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Remove="appsettings.json" /> |
|||
<Content Include="appsettings.json"> |
|||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|||
</Content> |
|||
<None Remove="appsettings.secrets.json" /> |
|||
<Content Include="appsettings.secrets.json"> |
|||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|||
</Content> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.0" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -1,23 +0,0 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
|
|||
namespace Lion.AbpPro.FileManagement.HttpApi.Client.ConsoleTestApp |
|||
{ |
|||
class Program |
|||
{ |
|||
static async Task Main(string[] args) |
|||
{ |
|||
await CreateHostBuilder(args).RunConsoleAsync(); |
|||
} |
|||
|
|||
public static IHostBuilder CreateHostBuilder(string[] args) => |
|||
Host.CreateDefaultBuilder(args) |
|||
.AddAppSettingsSecretsJson() |
|||
.ConfigureServices((hostContext, services) => |
|||
{ |
|||
services.AddHostedService<ConsoleTestAppHostedService>(); |
|||
}); |
|||
} |
|||
} |
|||
@ -1,21 +0,0 @@ |
|||
{ |
|||
"RemoteServices": { |
|||
"Default": { |
|||
"BaseUrl": "https://localhost:44384/" |
|||
}, |
|||
"FileManagement": { |
|||
"BaseUrl": "https://localhost:44373/" |
|||
} |
|||
}, |
|||
"IdentityClients": { |
|||
"Default": { |
|||
"GrantType": "password", |
|||
"ClientId": "FileManagement_App", |
|||
"ClientSecret": "1q2w3e*", |
|||
"UserName": "admin", |
|||
"UserPassword": "1q2w3E*", |
|||
"Authority": "https://localhost:44384/", |
|||
"Scope": "FileManagement" |
|||
} |
|||
} |
|||
} |
|||
@ -1,2 +0,0 @@ |
|||
{ |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
|
|||
namespace Lion.AbpPro.NotificationManagement.Controllers; |
|||
|
|||
public class HomeController : AbpController |
|||
{ |
|||
public ActionResult Index() |
|||
{ |
|||
return Redirect("~/swagger"); |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace Lion.AbpPro.NotificationManagement.EntityFrameworkCore; |
|||
|
|||
public class NotificationManagementHttpApiHostMigrationsDbContext : AbpDbContext<NotificationManagementHttpApiHostMigrationsDbContext> |
|||
{ |
|||
public NotificationManagementHttpApiHostMigrationsDbContext(DbContextOptions<NotificationManagementHttpApiHostMigrationsDbContext> options) |
|||
: base(options) |
|||
{ |
|||
|
|||
} |
|||
|
|||
protected override void OnModelCreating(ModelBuilder modelBuilder) |
|||
{ |
|||
base.OnModelCreating(modelBuilder); |
|||
|
|||
modelBuilder.ConfigureNotificationManagement(); |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
using System.IO; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Design; |
|||
using Microsoft.Extensions.Configuration; |
|||
|
|||
namespace Lion.AbpPro.NotificationManagement.EntityFrameworkCore; |
|||
|
|||
public class NotificationManagementHttpApiHostMigrationsDbContextFactory : IDesignTimeDbContextFactory<NotificationManagementHttpApiHostMigrationsDbContext> |
|||
{ |
|||
public NotificationManagementHttpApiHostMigrationsDbContext CreateDbContext(string[] args) |
|||
{ |
|||
var configuration = BuildConfiguration(); |
|||
|
|||
var builder = new DbContextOptionsBuilder<NotificationManagementHttpApiHostMigrationsDbContext>() |
|||
.UseMySql(configuration.GetConnectionString(NotificationManagementDbProperties.ConnectionStringName), MySqlServerVersion.LatestSupportedServerVersion); |
|||
return new NotificationManagementHttpApiHostMigrationsDbContext(builder.Options); |
|||
} |
|||
|
|||
private static IConfigurationRoot BuildConfiguration() |
|||
{ |
|||
var builder = new ConfigurationBuilder() |
|||
.SetBasePath(Directory.GetCurrentDirectory()) |
|||
.AddJsonFile("appsettings.json", optional: false); |
|||
|
|||
return builder.Build(); |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false"/> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,49 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
|||
|
|||
<Import Project="../../../../common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net6.0</TargetFramework> |
|||
<RootNamespace>Lion.AbpPro.NotificationManagement</RootNamespace> |
|||
<PreserveCompilationReferences>true</PreserveCompilationReferences> |
|||
<UserSecretsId>Lion.AbpPro.NotificationManagement-c2d31439-b723-48e2-b061-5ebd7aeb6010</UserSecretsId> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Serilog" Version="$(SerilogVersion)" /> |
|||
<PackageReference Include="Serilog.AspNetCore" Version="$(SerilogAspNetCoreVersion)" /> |
|||
<PackageReference Include="Serilog.Exceptions" Version="$(SerilogExceptionsVersion)" /> |
|||
<PackageReference Include="Serilog.Extensions.Logging" Version="$(SerilogExtensionsLoggingVersion)" /> |
|||
<PackageReference Include="Serilog.Settings.Configuration" Version="$(SerilogSettingsConfigurationVersion)" /> |
|||
<PackageReference Include="Serilog.Sinks.Console" Version="$(SerilogSinksConsoleVersion)" /> |
|||
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="$(SerilogSinksElasticsearchVersion)" /> |
|||
<PackageReference Include="Serilog.Sinks.File" Version="$(SerilogSinksFileVersion)" /> |
|||
<PackageReference Include="IdentityModel" Version="5.1.0" /> |
|||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(MicrosoftVersion)" /> |
|||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="$(MicrosoftVersion)" /> |
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="$(MicrosoftVersion)" /> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySQL" Version="$(AbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.Autofac" Version="$(AbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="$(AbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy" Version="$(AbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="$(AbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.Swashbuckle" Version="$(AbpPackageVersion)" /> |
|||
<PackageReference Include="Swashbuckle.AspNetCore" Version="$(SwashbuckleVersion)" /> |
|||
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="$(SwashbuckleVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\..\frameworks\CAP\src\Lion.AbpPro.CAP\Lion.AbpPro.CAP.csproj" /> |
|||
<ProjectReference Include="..\..\src\Lion.AbpPro.NotificationManagement.HttpApi\Lion.AbpPro.NotificationManagement.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\..\src\Lion.AbpPro.NotificationManagement.Application\Lion.AbpPro.NotificationManagement.Application.csproj" /> |
|||
<ProjectReference Include="..\..\src\Lion.AbpPro.NotificationManagement.EntityFrameworkCore\Lion.AbpPro.NotificationManagement.EntityFrameworkCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Compile Remove="Logs\**" /> |
|||
<Content Remove="Logs\**" /> |
|||
<EmbeddedResource Remove="Logs\**" /> |
|||
<None Remove="Logs\**" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,162 @@ |
|||
// <auto-generated />
|
|||
using System; |
|||
using Lion.AbpPro.NotificationManagement.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace Lion.AbpPro.NotificationManagement.Migrations |
|||
{ |
|||
[DbContext(typeof(NotificationManagementHttpApiHostMigrationsDbContext))] |
|||
[Migration("20220702015410_Init")] |
|||
partial class Init |
|||
{ |
|||
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) |
|||
.HasAnnotation("ProductVersion", "6.0.6") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 64); |
|||
|
|||
modelBuilder.Entity("Lion.AbpPro.NotificationManagement.Notifications.Aggregates.Notification", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasMaxLength(40) |
|||
.HasColumnType("varchar(40)") |
|||
.HasColumnName("ConcurrencyStamp"); |
|||
|
|||
b.Property<string>("Content") |
|||
.IsRequired() |
|||
.HasMaxLength(1024) |
|||
.HasColumnType("varchar(1024)"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<Guid?>("DeleterId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("DeleterId"); |
|||
|
|||
b.Property<DateTime?>("DeletionTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("DeletionTime"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<bool>("IsDeleted") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("tinyint(1)") |
|||
.HasDefaultValue(false) |
|||
.HasColumnName("IsDeleted"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.Property<int>("MessageType") |
|||
.HasColumnType("int"); |
|||
|
|||
b.Property<Guid>("SenderId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Title") |
|||
.IsRequired() |
|||
.HasMaxLength(256) |
|||
.HasColumnType("varchar(256)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.ToTable("Notification", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Lion.AbpPro.NotificationManagement.Notifications.Aggregates.NotificationSubscription", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<Guid?>("DeleterId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("DeleterId"); |
|||
|
|||
b.Property<DateTime?>("DeletionTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("DeletionTime"); |
|||
|
|||
b.Property<bool>("IsDeleted") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("tinyint(1)") |
|||
.HasDefaultValue(false) |
|||
.HasColumnName("IsDeleted"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.Property<Guid?>("NotificationId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<bool>("Read") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<DateTime?>("ReadTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid>("ReceiveId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("NotificationId"); |
|||
|
|||
b.ToTable("NotificationSubscription", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Lion.AbpPro.NotificationManagement.Notifications.Aggregates.NotificationSubscription", b => |
|||
{ |
|||
b.HasOne("Lion.AbpPro.NotificationManagement.Notifications.Aggregates.Notification", null) |
|||
.WithMany("NotificationSubscriptions") |
|||
.HasForeignKey("NotificationId"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Lion.AbpPro.NotificationManagement.Notifications.Aggregates.Notification", b => |
|||
{ |
|||
b.Navigation("NotificationSubscriptions"); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,87 @@ |
|||
using System; |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace Lion.AbpPro.NotificationManagement.Migrations |
|||
{ |
|||
public partial class Init : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.AlterDatabase() |
|||
.Annotation("MySql:CharSet", "utf8mb4"); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "Notification", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
|||
Title = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false) |
|||
.Annotation("MySql:CharSet", "utf8mb4"), |
|||
Content = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: false) |
|||
.Annotation("MySql:CharSet", "utf8mb4"), |
|||
MessageType = table.Column<int>(type: "int", nullable: false), |
|||
SenderId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
|||
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
|||
.Annotation("MySql:CharSet", "utf8mb4"), |
|||
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
|||
.Annotation("MySql:CharSet", "utf8mb4"), |
|||
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
|||
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
|||
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
|||
DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
|||
DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_Notification", x => x.Id); |
|||
}) |
|||
.Annotation("MySql:CharSet", "utf8mb4"); |
|||
|
|||
migrationBuilder.CreateTable( |
|||
name: "NotificationSubscription", |
|||
columns: table => new |
|||
{ |
|||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
|||
ReceiveId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
|||
Read = table.Column<bool>(type: "tinyint(1)", nullable: false), |
|||
ReadTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
|||
NotificationId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
|||
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
|||
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
|||
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
|||
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
|||
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
|||
DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
|||
DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true) |
|||
}, |
|||
constraints: table => |
|||
{ |
|||
table.PrimaryKey("PK_NotificationSubscription", x => x.Id); |
|||
table.ForeignKey( |
|||
name: "FK_NotificationSubscription_Notification_NotificationId", |
|||
column: x => x.NotificationId, |
|||
principalTable: "Notification", |
|||
principalColumn: "Id"); |
|||
}) |
|||
.Annotation("MySql:CharSet", "utf8mb4"); |
|||
|
|||
migrationBuilder.CreateIndex( |
|||
name: "IX_NotificationSubscription_NotificationId", |
|||
table: "NotificationSubscription", |
|||
column: "NotificationId"); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropTable( |
|||
name: "NotificationSubscription"); |
|||
|
|||
migrationBuilder.DropTable( |
|||
name: "Notification"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,160 @@ |
|||
// <auto-generated />
|
|||
using System; |
|||
using Lion.AbpPro.NotificationManagement.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
#nullable disable |
|||
|
|||
namespace Lion.AbpPro.NotificationManagement.Migrations |
|||
{ |
|||
[DbContext(typeof(NotificationManagementHttpApiHostMigrationsDbContext))] |
|||
partial class NotificationManagementHttpApiHostMigrationsDbContextModelSnapshot : ModelSnapshot |
|||
{ |
|||
protected override void BuildModel(ModelBuilder modelBuilder) |
|||
{ |
|||
#pragma warning disable 612, 618
|
|||
modelBuilder |
|||
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) |
|||
.HasAnnotation("ProductVersion", "6.0.6") |
|||
.HasAnnotation("Relational:MaxIdentifierLength", 64); |
|||
|
|||
modelBuilder.Entity("Lion.AbpPro.NotificationManagement.Notifications.Aggregates.Notification", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("ConcurrencyStamp") |
|||
.IsConcurrencyToken() |
|||
.HasMaxLength(40) |
|||
.HasColumnType("varchar(40)") |
|||
.HasColumnName("ConcurrencyStamp"); |
|||
|
|||
b.Property<string>("Content") |
|||
.IsRequired() |
|||
.HasMaxLength(1024) |
|||
.HasColumnType("varchar(1024)"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<Guid?>("DeleterId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("DeleterId"); |
|||
|
|||
b.Property<DateTime?>("DeletionTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("DeletionTime"); |
|||
|
|||
b.Property<string>("ExtraProperties") |
|||
.HasColumnType("longtext") |
|||
.HasColumnName("ExtraProperties"); |
|||
|
|||
b.Property<bool>("IsDeleted") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("tinyint(1)") |
|||
.HasDefaultValue(false) |
|||
.HasColumnName("IsDeleted"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.Property<int>("MessageType") |
|||
.HasColumnType("int"); |
|||
|
|||
b.Property<Guid>("SenderId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<string>("Title") |
|||
.IsRequired() |
|||
.HasMaxLength(256) |
|||
.HasColumnType("varchar(256)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.ToTable("Notification", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Lion.AbpPro.NotificationManagement.Notifications.Aggregates.NotificationSubscription", b => |
|||
{ |
|||
b.Property<Guid>("Id") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<DateTime>("CreationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("CreationTime"); |
|||
|
|||
b.Property<Guid?>("CreatorId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("CreatorId"); |
|||
|
|||
b.Property<Guid?>("DeleterId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("DeleterId"); |
|||
|
|||
b.Property<DateTime?>("DeletionTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("DeletionTime"); |
|||
|
|||
b.Property<bool>("IsDeleted") |
|||
.ValueGeneratedOnAdd() |
|||
.HasColumnType("tinyint(1)") |
|||
.HasDefaultValue(false) |
|||
.HasColumnName("IsDeleted"); |
|||
|
|||
b.Property<DateTime?>("LastModificationTime") |
|||
.HasColumnType("datetime(6)") |
|||
.HasColumnName("LastModificationTime"); |
|||
|
|||
b.Property<Guid?>("LastModifierId") |
|||
.HasColumnType("char(36)") |
|||
.HasColumnName("LastModifierId"); |
|||
|
|||
b.Property<Guid?>("NotificationId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.Property<bool>("Read") |
|||
.HasColumnType("tinyint(1)"); |
|||
|
|||
b.Property<DateTime?>("ReadTime") |
|||
.HasColumnType("datetime(6)"); |
|||
|
|||
b.Property<Guid>("ReceiveId") |
|||
.HasColumnType("char(36)"); |
|||
|
|||
b.HasKey("Id"); |
|||
|
|||
b.HasIndex("NotificationId"); |
|||
|
|||
b.ToTable("NotificationSubscription", (string)null); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Lion.AbpPro.NotificationManagement.Notifications.Aggregates.NotificationSubscription", b => |
|||
{ |
|||
b.HasOne("Lion.AbpPro.NotificationManagement.Notifications.Aggregates.Notification", null) |
|||
.WithMany("NotificationSubscriptions") |
|||
.HasForeignKey("NotificationId"); |
|||
}); |
|||
|
|||
modelBuilder.Entity("Lion.AbpPro.NotificationManagement.Notifications.Aggregates.Notification", b => |
|||
{ |
|||
b.Navigation("NotificationSubscriptions"); |
|||
}); |
|||
#pragma warning restore 612, 618
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,253 @@ |
|||
using System; |
|||
using System.Linq; |
|||
using Lion.AbpPro.CAP; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Cors; |
|||
using Microsoft.AspNetCore.DataProtection; |
|||
using Microsoft.Extensions.Caching.Distributed; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.OpenApi.Models; |
|||
using Lion.AbpPro.NotificationManagement.EntityFrameworkCore; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Savorboard.CAP.InMemoryMessageQueue; |
|||
using StackExchange.Redis; |
|||
using Swashbuckle.AspNetCore.SwaggerUI; |
|||
using Volo.Abp; |
|||
using Volo.Abp.AspNetCore.Mvc.AntiForgery; |
|||
using Volo.Abp.AspNetCore.Serilog; |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.Caching.StackExchangeRedis; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore.MySQL; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.Swashbuckle; |
|||
using Volo.Abp.VirtualFileSystem; |
|||
|
|||
namespace Lion.AbpPro.NotificationManagement; |
|||
|
|||
[DependsOn( |
|||
typeof(NotificationManagementApplicationModule), |
|||
typeof(NotificationManagementEntityFrameworkCoreModule), |
|||
typeof(NotificationManagementHttpApiModule), |
|||
typeof(AbpAutofacModule), |
|||
typeof(AbpCachingStackExchangeRedisModule), |
|||
typeof(AbpAspNetCoreSerilogModule), |
|||
typeof(AbpSwashbuckleModule), |
|||
typeof(AbpProAbpCapModule), |
|||
typeof(AbpEntityFrameworkCoreMySQLModule) |
|||
)] |
|||
public class NotificationManagementHttpApiHostModule : AbpModule |
|||
{ |
|||
private const string DefaultCorsPolicyName = "Default"; |
|||
|
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
ConfigureVirtualFileSystem(); |
|||
ConfigureSwaggerServices(context); |
|||
ConfigAntiForgery(); |
|||
ConfigureLocalization(); |
|||
ConfigureCap(context); |
|||
ConfigureCache(context); |
|||
ConfigureCors(context); |
|||
ConfigDB(); |
|||
} |
|||
|
|||
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|||
{ |
|||
var app = context.GetApplicationBuilder(); |
|||
var env = context.GetEnvironment(); |
|||
app.UseCorrelationId(); |
|||
app.UseStaticFiles(); |
|||
app.UseRouting(); |
|||
app.UseCors(DefaultCorsPolicyName); |
|||
app.UseAuthentication(); |
|||
app.UseAbpRequestLocalization(); |
|||
app.UseAuthorization(); |
|||
app.UseSwagger(); |
|||
app.UseAbpSwaggerUI(options => |
|||
{ |
|||
options.SwaggerEndpoint("/swagger/v1/swagger.json", "NotificationManagement API"); |
|||
options.DocExpansion(DocExpansion.None); |
|||
options.DefaultModelExpandDepth(-2); |
|||
}); |
|||
app.UseAuditing(); |
|||
app.UseAbpSerilogEnrichers(); |
|||
app.UseConfiguredEndpoints(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 配置虚拟文件系统
|
|||
/// </summary>
|
|||
private void ConfigureVirtualFileSystem() |
|||
{ |
|||
Configure<AbpVirtualFileSystemOptions>(options => { options.FileSets.AddEmbedded<NotificationManagementHttpApiHostModule>(); }); |
|||
} |
|||
|
|||
private void ConfigDB() |
|||
{ |
|||
Configure<AbpDbContextOptions>(options => |
|||
{ |
|||
/* The main point to change your DBMS. |
|||
* See also OperationsMigrationsDbContextFactory for EF Core tooling. */ |
|||
options.UseMySQL(); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureCap(ServiceConfigurationContext context) |
|||
{ |
|||
var configuration = context.Services.GetConfiguration(); |
|||
var enabled = configuration.GetValue("Cap:Enabled", false); |
|||
if (enabled) |
|||
{ |
|||
context.AddAbpCap(capOptions => |
|||
{ |
|||
capOptions.UseEntityFramework<NotificationManagementHttpApiHostMigrationsDbContext>(); |
|||
capOptions.UseRabbitMQ(option => |
|||
{ |
|||
option.HostName = configuration.GetValue<string>("Cap:RabbitMq:HostName"); |
|||
option.UserName = configuration.GetValue<string>("Cap:RabbitMq:UserName"); |
|||
option.Password = configuration.GetValue<string>("Cap:RabbitMq:Password"); |
|||
}); |
|||
|
|||
var hostingEnvironment = context.Services.GetHostingEnvironment(); |
|||
bool auth = !hostingEnvironment.IsDevelopment(); |
|||
capOptions.UseDashboard(options => { options.UseAuth = auth; }); |
|||
}); |
|||
} |
|||
else |
|||
{ |
|||
context.AddAbpCap(capOptions => |
|||
{ |
|||
capOptions.UseInMemoryStorage(); |
|||
capOptions.UseInMemoryMessageQueue(); |
|||
var hostingEnvironment = context.Services.GetHostingEnvironment(); |
|||
bool auth = !hostingEnvironment.IsDevelopment(); |
|||
capOptions.UseDashboard(options => { options.UseAuth = auth; }); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 配置SwaggerUI
|
|||
/// </summary>
|
|||
/// <param name="context"></param>
|
|||
private static void ConfigureSwaggerServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddSwaggerGen( |
|||
options => |
|||
{ |
|||
options.SwaggerDoc("v1", new OpenApiInfo { Title = "NotificationManagement API", Version = "v1" }); |
|||
options.DocInclusionPredicate((docName, description) => true); |
|||
|
|||
|
|||
#region 多语言
|
|||
|
|||
options.AddSecurityDefinition("ApiKey", new OpenApiSecurityScheme |
|||
{ |
|||
Type = SecuritySchemeType.ApiKey, |
|||
In = ParameterLocation.Header, |
|||
Name = "Accept-Language", |
|||
Description = "多语言" |
|||
}); |
|||
|
|||
options.AddSecurityRequirement(new OpenApiSecurityRequirement |
|||
{ |
|||
{ |
|||
new OpenApiSecurityScheme |
|||
{ |
|||
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "ApiKey" } |
|||
}, |
|||
new string[] { } |
|||
} |
|||
}); |
|||
|
|||
#endregion
|
|||
}); |
|||
} |
|||
|
|||
private void ConfigAntiForgery() |
|||
{ |
|||
Configure<AbpAntiForgeryOptions>(options => { options.AutoValidate = false; }); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 配置本地化
|
|||
/// </summary>
|
|||
private void ConfigureLocalization() |
|||
{ |
|||
Configure<AbpLocalizationOptions>(options => |
|||
{ |
|||
options.Languages.Add(new LanguageInfo("ar", "ar", "العربية")); |
|||
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština")); |
|||
options.Languages.Add(new LanguageInfo("en", "en", "English")); |
|||
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)")); |
|||
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("is", "is", "Icelandic", "is")); |
|||
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it")); |
|||
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); |
|||
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português")); |
|||
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română")); |
|||
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский")); |
|||
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak")); |
|||
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", "繁體中文")); |
|||
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch")); |
|||
options.Languages.Add(new LanguageInfo("es", "es", "Español")); |
|||
}); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Redis缓存
|
|||
/// </summary>
|
|||
/// <param name="context"></param>
|
|||
private void ConfigureCache(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpDistributedCacheOptions>(options => |
|||
{ |
|||
options.KeyPrefix = "NotificationManagement:"; |
|||
options.GlobalCacheEntryOptions = new DistributedCacheEntryOptions |
|||
{ |
|||
// 全局缓存有效时间
|
|||
AbsoluteExpiration = DateTimeOffset.UtcNow.AddHours(2) |
|||
}; |
|||
}); |
|||
|
|||
var configuration = context.Services.GetConfiguration(); |
|||
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); |
|||
context.Services |
|||
.AddDataProtection() |
|||
.PersistKeysToStackExchangeRedis(redis, "YH.Wms.Operations-Keys"); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 配置跨域
|
|||
/// </summary>
|
|||
private void ConfigureCors(ServiceConfigurationContext context) |
|||
{ |
|||
var configuration = context.Services.GetConfiguration(); |
|||
context.Services.AddCors(options => |
|||
{ |
|||
options.AddPolicy(DefaultCorsPolicyName, builder => |
|||
{ |
|||
builder |
|||
.WithOrigins( |
|||
configuration["App:CorsOrigins"] |
|||
.Split(",", StringSplitOptions.RemoveEmptyEntries) |
|||
.Select(o => o.RemovePostFix("/")) |
|||
.ToArray() |
|||
) |
|||
.WithAbpExposedHeaders() |
|||
.SetIsOriginAllowedToAllowWildcardSubdomains() |
|||
.AllowAnyHeader() |
|||
.AllowAnyMethod() |
|||
.AllowCredentials(); |
|||
}); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Serilog; |
|||
|
|||
namespace Lion.AbpPro.NotificationManagement; |
|||
|
|||
public class Program |
|||
{ |
|||
public static void Main(string[] args) |
|||
{ |
|||
CreateHostBuilder(args).Build().Run(); |
|||
} |
|||
|
|||
public static IHostBuilder CreateHostBuilder(string[] args) |
|||
{ |
|||
return Host.CreateDefaultBuilder(args) |
|||
.ConfigureWebHostDefaults(webBuilder => |
|||
{ |
|||
webBuilder.ConfigureKestrel((context, options) => { options.Limits.MaxRequestBodySize = 1024 * 50; }); |
|||
webBuilder.UseStartup<Startup>(); |
|||
}) |
|||
.UseSerilog().UseAutofac(); |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
{ |
|||
"profiles": { |
|||
"Lion.AbpPro.NotificationManagement.HttpApi.Host": { |
|||
"commandName": "Project", |
|||
"launchBrowser": true, |
|||
"applicationUrl": "http://localhost:5001", |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Logging; |
|||
|
|||
namespace Lion.AbpPro.NotificationManagement; |
|||
|
|||
public class Startup |
|||
{ |
|||
public void ConfigureServices(IServiceCollection services) |
|||
{ |
|||
services.AddApplication<NotificationManagementHttpApiHostModule>(); |
|||
} |
|||
|
|||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) |
|||
{ |
|||
app.InitializeApplication(); |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
{ |
|||
"App": { |
|||
"CorsOrigins": "https://*.NotificationManagement.com,http://localhost:4200,http://localhost:44307,https://localhost:44307" |
|||
}, |
|||
"ConnectionStrings": { |
|||
"Default": "Data Source=localhost;Database=LionAbpProDB;uid=root;pwd=mypassword;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true", |
|||
"NotificationManagement":"Data Source=localhost;Database=NotificationManagement;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true" |
|||
}, |
|||
"Redis": { |
|||
"Configuration": "localhost,password=mypassword,defaultdatabase=1" |
|||
}, |
|||
"Cap": { |
|||
"Enabled": "false", |
|||
"RabbitMq": { |
|||
"HostName": "localhost", |
|||
"UserName": "admin", |
|||
"Password": "1q2w3E*" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,76 @@ |
|||
// Global using directives
|
|||
|
|||
global using System; |
|||
global using System.Collections.Generic; |
|||
global using System.IO; |
|||
global using System.Linq; |
|||
global using System.Text; |
|||
global using System.Text.RegularExpressions; |
|||
global using System.Threading.Tasks; |
|||
global using Hangfire; |
|||
global using Hangfire.Common; |
|||
global using Hangfire.Dashboard; |
|||
global using Hangfire.MySql; |
|||
global using Hangfire.States; |
|||
global using Hangfire.Storage; |
|||
global using Lion.AbpPro.CAP; |
|||
global using Lion.AbpPro.ConfigurationOptions; |
|||
global using Lion.AbpPro.EntityFrameworkCore; |
|||
global using Lion.AbpPro.Extension.Customs.Dtos; |
|||
global using Lion.AbpPro.Extensions; |
|||
global using Lion.AbpPro.Extensions.Hangfire; |
|||
global using Lion.AbpPro.Extensions.Middlewares; |
|||
global using Lion.AbpPro.Extensions.System; |
|||
global using Lion.AbpPro.Localization; |
|||
global using Lion.AbpPro.MultiTenancy; |
|||
global using Lion.AbpPro.Shared.Hosting.Microservices; |
|||
global using Lion.AbpPro.Shared.Hosting.Microservices.Microsoft.AspNetCore.Builder; |
|||
global using Lion.AbpPro.Shared.Hosting.Microservices.Microsoft.AspNetCore.MVC.Filters; |
|||
global using Lion.AbpPro.Shared.Hosting.Microservices.Swaggers; |
|||
global using Magicodes.ExporterAndImporter.Core; |
|||
global using Magicodes.ExporterAndImporter.Excel; |
|||
global using Microsoft.AspNetCore.Authentication.JwtBearer; |
|||
global using Microsoft.AspNetCore.Builder; |
|||
global using Microsoft.AspNetCore.DataProtection; |
|||
global using Microsoft.AspNetCore.Hosting; |
|||
global using Microsoft.AspNetCore.Http; |
|||
global using Microsoft.AspNetCore.Identity; |
|||
global using Microsoft.AspNetCore.Mvc; |
|||
global using Microsoft.AspNetCore.Mvc.Abstractions; |
|||
global using Microsoft.AspNetCore.Mvc.Filters; |
|||
global using Microsoft.Extensions.Configuration; |
|||
global using Microsoft.Extensions.DependencyInjection; |
|||
global using Microsoft.Extensions.Hosting; |
|||
global using Microsoft.Extensions.Logging; |
|||
global using Microsoft.Extensions.Logging.Abstractions; |
|||
global using Microsoft.Extensions.Options; |
|||
global using Microsoft.IdentityModel.Tokens; |
|||
global using Microsoft.OpenApi.Models; |
|||
global using Savorboard.CAP.InMemoryMessageQueue; |
|||
global using Serilog; |
|||
global using Serilog.Events; |
|||
global using StackExchange.Redis; |
|||
global using Swashbuckle.AspNetCore.SwaggerUI; |
|||
global using Volo.Abp; |
|||
global using Volo.Abp.Account.Web; |
|||
global using Volo.Abp.AspNetCore.Auditing; |
|||
global using Volo.Abp.AspNetCore.Authentication.JwtBearer; |
|||
global using Volo.Abp.AspNetCore.ExceptionHandling; |
|||
global using Volo.Abp.AspNetCore.Mvc; |
|||
global using Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy; |
|||
global using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; |
|||
global using Volo.Abp.AspNetCore.Serilog; |
|||
global using Volo.Abp.Auditing; |
|||
global using Volo.Abp.Authorization; |
|||
global using Volo.Abp.BackgroundJobs; |
|||
global using Volo.Abp.BackgroundJobs.Hangfire; |
|||
global using Volo.Abp.Caching; |
|||
global using Volo.Abp.Caching.StackExchangeRedis; |
|||
global using Volo.Abp.DependencyInjection; |
|||
global using Volo.Abp.Domain.Entities; |
|||
global using Volo.Abp.ExceptionHandling; |
|||
global using Volo.Abp.Http; |
|||
global using Volo.Abp.Json; |
|||
global using Volo.Abp.Modularity; |
|||
global using Volo.Abp.Users; |
|||
global using Volo.Abp.Validation; |
|||
Loading…
Reference in new issue