109 changed files with 3564 additions and 1 deletions
@ -0,0 +1,9 @@ |
|||
.vs |
|||
LocalNuget |
|||
*.DotSettings.user |
|||
**/*.csproj.user |
|||
nupkg |
|||
consoles |
|||
*.configs.cache |
|||
*.nupkg |
|||
*.nuspec |
|||
@ -0,0 +1,99 @@ |
|||
{ |
|||
"$schema": "http://json.schemastore.org/template", |
|||
"author": "colin.in@foxmail.com", |
|||
"classifications": [ "micro", "webapi", "cloud" ], |
|||
"name": "LINGYUN.Abp.MicroService", |
|||
"identity": "LINGYUN.Abp.MicroService", //模板唯一标识 |
|||
"groupIdentity": "LINGYUN.Abp.Application", |
|||
"shortName": "lam", |
|||
"tags": { |
|||
"language": "C#", |
|||
"type": "project" |
|||
}, |
|||
"sourceName": "ProjectName", |
|||
"preferNameDirectory": true, |
|||
"symbols": { |
|||
"AuthenticationScheme": { |
|||
"type": "parameter", |
|||
"description": "Authentication Scheme", |
|||
"datatype": "choice", |
|||
"defaultValue": "IdentityServer4", |
|||
"isRequired": false, |
|||
"choices": [ |
|||
{ |
|||
"choice": "IdentityServer4", |
|||
"description": "IdentityServer4" |
|||
}, |
|||
{ |
|||
"choice": "OpenIddict", |
|||
"description": "OpenIddict" |
|||
} |
|||
] |
|||
}, |
|||
"DatabaseManagement": { |
|||
"type": "parameter", |
|||
"description": "Database Management", |
|||
"dataType": "choice", |
|||
"defaultValue": "MySQL", |
|||
"isRequired": false, |
|||
"choices": [ |
|||
{ |
|||
"choice": "SqlServer", |
|||
"description": "Sql Server" |
|||
}, |
|||
{ |
|||
"choice": "MySQL", |
|||
"description": "My SQL" |
|||
}, |
|||
{ |
|||
"choice": "Sqlite", |
|||
"description": "Sqlite" |
|||
}, |
|||
{ |
|||
"choice": "Oracle", |
|||
"description": "Oracle" |
|||
}, |
|||
{ |
|||
"choice": "OracleDevart", |
|||
"description": "Oracle Devart Driver" |
|||
}, |
|||
{ |
|||
"choice": "PostgreSql", |
|||
"description": "Postgre Sql" |
|||
} |
|||
] |
|||
}, |
|||
"SqlServer": { |
|||
"type": "computed", |
|||
"value": "(DatabaseManagement == \"SqlServer\")" |
|||
}, |
|||
"MySQL": { |
|||
"type": "computed", |
|||
"value": "(DatabaseManagement == \"MySQL\")" |
|||
}, |
|||
"Sqlite": { |
|||
"type": "computed", |
|||
"value": "(DatabaseManagement == \"Sqlite\")" |
|||
}, |
|||
"Oracle": { |
|||
"type": "computed", |
|||
"value": "(DatabaseManagement == \"Oracle\")" |
|||
}, |
|||
"OracleDevart": { |
|||
"type": "computed", |
|||
"value": "(DatabaseManagement == \"Oracle.Devart\")" |
|||
}, |
|||
"PostgreSql": { |
|||
"type": "computed", |
|||
"value": "(DatabaseManagement == \"PostgreSql\")" |
|||
}, |
|||
"IdentityServer4": { |
|||
"type": "computed", |
|||
"value": "(AuthenticationScheme == \"IdentityServer4\")" |
|||
}, |
|||
"OpenIddict": { |
|||
"type": "computed", |
|||
"value": "(AuthenticationScheme == \"OpenIddict\")" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
<Project> |
|||
<PropertyGroup> |
|||
<AgileConfigClientPackageVersion>1.6.9</AgileConfigClientPackageVersion> |
|||
<VoloAbpPackageVersion>7.0.2</VoloAbpPackageVersion> |
|||
<LINGYUNAbpPackageVersion>7.0.2</LINGYUNAbpPackageVersion> |
|||
<DotNetCoreCAPPackageVersion>7.0.3</DotNetCoreCAPPackageVersion> |
|||
<DaprPackageVersion>1.10.0</DaprPackageVersion> |
|||
<DistributedLockRedisPackageVersion>1.0.2</DistributedLockRedisPackageVersion> |
|||
<OpenTelemetryExtensionsHostingPackageVersion>1.0.0-rc8</OpenTelemetryExtensionsHostingPackageVersion> |
|||
<OpenTelemetryExporterZipkinPackageVersion>1.3.1</OpenTelemetryExporterZipkinPackageVersion> |
|||
<OpenTelemetryInstrumentationAspNetCorePackageVersion>1.0.0-rc8</OpenTelemetryInstrumentationAspNetCorePackageVersion> |
|||
<OpenTelemetryInstrumentationHttpPackageVersion>1.0.0-rc8</OpenTelemetryInstrumentationHttpPackageVersion> |
|||
<OpenTelemetryContribInstrumentationEntityFrameworkCorePackageVersion>1.0.0-beta2</OpenTelemetryContribInstrumentationEntityFrameworkCorePackageVersion> |
|||
<SerilogPackageVersion>2.10.0</SerilogPackageVersion> |
|||
<SerilogSinksAsyncPackageVersion>1.5.0</SerilogSinksAsyncPackageVersion> |
|||
<SerilogAspNetCorePackageVersion>5.0.0</SerilogAspNetCorePackageVersion> |
|||
<SerilogEnrichersEnvironmentPackageVersion>2.2.0</SerilogEnrichersEnvironmentPackageVersion> |
|||
<SerilogEnrichersAssemblyPackageVersion>2.0.0</SerilogEnrichersAssemblyPackageVersion> |
|||
<SerilogEnrichersProcessPackageVersion>2.0.1</SerilogEnrichersProcessPackageVersion> |
|||
<SerilogEnrichersThreadPackageVersion>3.1.0</SerilogEnrichersThreadPackageVersion> |
|||
<SerilogExtensionsLoggingPackageVersion>3.0.1</SerilogExtensionsLoggingPackageVersion> |
|||
<SerilogSettingsConfigurationPackageVersion>3.4.0</SerilogSettingsConfigurationPackageVersion> |
|||
<SerilogSinksConsolePackageVersion>4.0.0</SerilogSinksConsolePackageVersion> |
|||
<SerilogSinksElasticsearchPackageVersion>8.4.1</SerilogSinksElasticsearchPackageVersion> |
|||
<SerilogSinksFilePackageVersion>5.0.0</SerilogSinksFilePackageVersion> |
|||
<SwashbuckleAspNetCorePackageVersion>6.1.5</SwashbuckleAspNetCorePackageVersion> |
|||
<MicrosoftPackageVersion>7.0.*</MicrosoftPackageVersion> |
|||
<MicrosoftEntityFrameworkCorePackageVersion>7.0.2</MicrosoftEntityFrameworkCorePackageVersion> |
|||
<XunitTestPackageVersion>2.4.1</XunitTestPackageVersion> |
|||
<ShouldlyPackageVersion>3.0.2</ShouldlyPackageVersion> |
|||
<NSubstitutePackageVersion>4.2.1</NSubstitutePackageVersion> |
|||
</PropertyGroup> |
|||
</Project> |
|||
@ -0,0 +1,36 @@ |
|||
<Project> |
|||
<PropertyGroup> |
|||
<LangVersion>latest</LangVersion> |
|||
<Version>7.0.2</Version> |
|||
<Authors>colin</Authors> |
|||
<NoWarn>$(NoWarn);CS1591;CS0436</NoWarn> |
|||
<PackageProjectUrl>https://github.com/colinin/abp-next-admin</PackageProjectUrl> |
|||
<PackageLicenseExpression>MIT</PackageLicenseExpression> |
|||
<RepositoryType>git</RepositoryType> |
|||
<RepositoryUrl>https://github.com/colinin/abp-next-admin</RepositoryUrl> |
|||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<Compile Remove="LocalNuget\**" /> |
|||
<EmbeddedResource Remove="LocalNuget\**" /> |
|||
<None Remove="LocalNuget\**" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Compile Remove="Logs\**" /> |
|||
<EmbeddedResource Remove="Logs\**" /> |
|||
<None Remove="Logs\**" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Compile Remove="Modules\**" /> |
|||
<EmbeddedResource Remove="Modules\**" /> |
|||
<None Remove="Modules\**" /> |
|||
</ItemGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> |
|||
<OutputPath>$(SolutionDir)LocalNuget</OutputPath> |
|||
</PropertyGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,9 @@ |
|||
<Project> |
|||
<ItemGroup> |
|||
<PackageReference Include="ConfigureAwait.Fody" Version="3.3.1" PrivateAssets="All" /> |
|||
<PackageReference Include="Fody" Version="6.6.1"> |
|||
<PrivateAssets>All</PrivateAssets> |
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> |
|||
</PackageReference> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -0,0 +1,49 @@ |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using PackageName.CompanyName.ProjectName.DbMigrator.EntityFrameworkCore; |
|||
using Serilog; |
|||
using Volo.Abp; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.DbMigrator; |
|||
|
|||
public class DbMigratorHostedService : IHostedService |
|||
{ |
|||
private readonly IHostApplicationLifetime _hostApplicationLifetime; |
|||
private readonly IConfiguration _configuration; |
|||
|
|||
public DbMigratorHostedService( |
|||
IHostApplicationLifetime hostApplicationLifetime, |
|||
IConfiguration configuration) |
|||
{ |
|||
_hostApplicationLifetime = hostApplicationLifetime; |
|||
_configuration = configuration; |
|||
} |
|||
|
|||
public async Task StartAsync(CancellationToken cancellationToken) |
|||
{ |
|||
using var application = await AbpApplicationFactory |
|||
.CreateAsync<PackageNameCompanyNameProjectNameDbMigratorModule>(options => |
|||
{ |
|||
options.Services.ReplaceConfiguration(_configuration); |
|||
options.UseAutofac(); |
|||
options.Services.AddLogging(c => c.AddSerilog()); |
|||
}); |
|||
await application.InitializeAsync(); |
|||
|
|||
await application |
|||
.ServiceProvider |
|||
.GetRequiredService<ProjectNameDbMigrationService>() |
|||
.MigrateAsync(); |
|||
|
|||
await application.ShutdownAsync(); |
|||
|
|||
_hostApplicationLifetime.StopApplication(); |
|||
} |
|||
|
|||
public Task StopAsync(CancellationToken cancellationToken) |
|||
{ |
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
|
|||
@ -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,44 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="../../common.props" /> |
|||
<Import Project="../../configureawait.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>net7.0</TargetFramework> |
|||
<ImplicitUsings>enable</ImplicitUsings> |
|||
<Nullable>enable</Nullable> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Serilog.Sinks.Async" Version="$(SerilogSinksAsyncPackageVersion)" /> |
|||
<PackageReference Include="Serilog.Extensions.Logging" Version="$(SerilogExtensionsLoggingPackageVersion)" /> |
|||
<PackageReference Include="Serilog.Sinks.File" Version="$(SerilogSinksFilePackageVersion)" /> |
|||
<PackageReference Include="Serilog.Sinks.Console" Version="$(SerilogSinksConsolePackageVersion)" /> |
|||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="$(MicrosoftPackageVersion)" /> |
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="$(MicrosoftPackageVersion)"> |
|||
<PrivateAssets>all</PrivateAssets> |
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
|||
</PackageReference> |
|||
<PackageReference Include="Volo.Abp.Autofac" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySql" Version="$(VoloAbpPackageVersion)" Condition="'$(MySQL)'=='true'" /> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="$(VoloAbpPackageVersion)" Condition="'$(SqlServer)'=='true'" /> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.Sqlite" Version="$(VoloAbpPackageVersion)" Condition="'$(Sqlite)'=='true'" /> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.Oracle" Version="$(VoloAbpPackageVersion)" Condition="'$(Oracle)'=='true'" /> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.Oracle.Devart" Version="$(VoloAbpPackageVersion)" Condition="'$(OracleDevart)'=='true'" /> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.PostgreSql" Version="$(VoloAbpPackageVersion)" Condition="'$(PostgreSql)'=='true'" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Compile Remove="Logs\**" /> |
|||
<Content Remove="Logs\**" /> |
|||
<EmbeddedResource Remove="Logs\**" /> |
|||
<None Remove="Logs\**" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\PackageName.CompanyName.ProjectName.EntityFrameworkCore\PackageName.CompanyName.ProjectName.EntityFrameworkCore.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,13 @@ |
|||
using PackageName.CompanyName.ProjectName.EntityFrameworkCore; |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.DbMigrator; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpAutofacModule), |
|||
typeof(ProjectNameEntityFrameworkCoreModule) |
|||
)] |
|||
public class PackageNameCompanyNameProjectNameDbMigratorModule : AbpModule |
|||
{ |
|||
} |
|||
@ -0,0 +1,40 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Microsoft.Extensions.Logging; |
|||
using Serilog; |
|||
using Serilog.Events; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.DbMigrator; |
|||
|
|||
public class Program |
|||
{ |
|||
public async static Task Main(string[] args) |
|||
{ |
|||
Log.Logger = new LoggerConfiguration() |
|||
.MinimumLevel.Information() |
|||
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) |
|||
.MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) |
|||
#if DEBUG
|
|||
.MinimumLevel.Override("PackageName.CompanyName.ProjectName", LogEventLevel.Debug) |
|||
#else
|
|||
.MinimumLevel.Override("PackageName.CompanyName.ProjectName", LogEventLevel.Information) |
|||
#endif
|
|||
.Enrich.FromLogContext() |
|||
.WriteTo.Async(c => c.File("Logs/logs.txt")) |
|||
.WriteTo.Async(c => c.Console()) |
|||
.CreateLogger(); |
|||
|
|||
await CreateHostBuilder(args).RunConsoleAsync(); |
|||
} |
|||
|
|||
public static IHostBuilder CreateHostBuilder(string[] args) |
|||
{ |
|||
return Host.CreateDefaultBuilder(args) |
|||
.AddAppSettingsSecretsJson() |
|||
.ConfigureLogging((context, logging) => logging.ClearProviders()) |
|||
.ConfigureServices((hostContext, services) => |
|||
{ |
|||
services.AddHostedService<DbMigratorHostedService>(); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,145 @@ |
|||
{ |
|||
"AgileConfig": { |
|||
"IsEnabled": false, |
|||
"env": "DEV", |
|||
"appId": "PackageName.CompanyName.ProjectName", |
|||
"secret": "1q2w3E*", |
|||
"nodes": "http://127.0.0.1:15000", |
|||
"name": "PackageName.CompanyName.ProjectName", |
|||
"tag": "PackageName.CompanyName.ProjectName" |
|||
}, |
|||
"Auditing": { |
|||
"AllEntitiesSelector": true |
|||
}, |
|||
"DistributedCache": { |
|||
"HideErrors": true, |
|||
"KeyPrefix": "LINGYUN.Abp.Application", |
|||
"GlobalCacheEntryOptions": { |
|||
"SlidingExpiration": "30:00:00", |
|||
"AbsoluteExpirationRelativeToNow": "60:00:00" |
|||
} |
|||
}, |
|||
"ConnectionStrings": { |
|||
"Default": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456", |
|||
"ProjectName": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456", |
|||
"AbpSaas": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456", |
|||
"AbpFeatureManagement": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456", |
|||
"AbpPermissionManagement": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456", |
|||
"AbpSettingManagement": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456", |
|||
"AbpLocalizationManagement": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456", |
|||
"AbpTextTemplating": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456" |
|||
}, |
|||
"DistributedLock": { |
|||
"IsEnabled": true, |
|||
"Redis": { |
|||
"Configuration": "127.0.0.1,defaultDatabase=15" |
|||
} |
|||
}, |
|||
"OpenTelemetry": { |
|||
"IsEnabled": true, |
|||
"ZipKin": { |
|||
"Endpoint": "http://127.0.0.1:9411/api/v2/spans" |
|||
} |
|||
}, |
|||
"RemoteServices": {}, |
|||
"IdentityClients": { |
|||
"InternalServiceClient": { |
|||
"Authority": "http://127.0.0.1:44385", |
|||
"RequireHttps": false, |
|||
"GrantType": "client_credentials", |
|||
"Scope": "lingyun-abp-application", |
|||
"ClientId": "InternalServiceClient", |
|||
"ClientSecret": "1q2w3E*" |
|||
} |
|||
}, |
|||
"CAP": { |
|||
"EventBus": { |
|||
"DefaultGroupName": "ProjectName", |
|||
"GroupNamePrefix": "Dev", |
|||
"Version": "v1", |
|||
"FailedRetryInterval": 300, |
|||
"FailedRetryCount": 10 |
|||
}, |
|||
"MySql": { |
|||
"TableNamePrefix": "ProjectName_cap", |
|||
"ConnectionString": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456" |
|||
}, |
|||
"SqlServer": { |
|||
"TableNamePrefix": "ProjectName_cap", |
|||
"ConnectionString": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456" |
|||
}, |
|||
"Sqlite": { |
|||
"TableNamePrefix": "ProjectName_cap", |
|||
"ConnectionString": "Data Source=./cap.db" |
|||
}, |
|||
"Oracle": { |
|||
"TableNamePrefix": "ProjectName_cap", |
|||
"ConnectionString": "Data Source=ProjectName;Integrated Security=yes;" |
|||
}, |
|||
"PostgreSql": { |
|||
"TableNamePrefix": "ProjectName_cap", |
|||
"ConnectionString": "Host=localhost;Port=5432;Database=ProjectName;User ID=root;Password=123456;" |
|||
}, |
|||
"RabbitMQ": { |
|||
"HostName": "127.0.0.1", |
|||
"Port": 5672, |
|||
"UserName": "admin", |
|||
"Password": "123456", |
|||
"ExchangeName": "LINGYUN.Abp.Application", |
|||
"VirtualHost": "/" |
|||
} |
|||
}, |
|||
"Redis": { |
|||
"Configuration": "127.0.0.1,defaultDatabase=10", |
|||
"InstanceName": "LINGYUN.Abp.Application" |
|||
}, |
|||
"AuthServer": { |
|||
"Authority": "http://127.0.0.1:44385/", |
|||
"ApiName": "lingyun-abp-application", |
|||
"SwaggerClientId": "InternalServiceClient", |
|||
"SwaggerClientSecret": "1q2w3E*" |
|||
}, |
|||
"Logging": { |
|||
"Serilog": { |
|||
"Elasticsearch": { |
|||
"IndexFormat": "abp.dev.logging-{0:yyyy.MM.dd}" |
|||
} |
|||
} |
|||
}, |
|||
"AuditLogging": { |
|||
"Elasticsearch": { |
|||
"IndexPrefix": "abp.dev.auditing" |
|||
} |
|||
}, |
|||
"Elasticsearch": { |
|||
"NodeUris": "http://127.0.0.1:9200" |
|||
}, |
|||
"Serilog": { |
|||
"MinimumLevel": { |
|||
"Default": "Debug", |
|||
"Override": { |
|||
"System": "Warning", |
|||
"Microsoft": "Warning", |
|||
"DotNetCore": "Debug" |
|||
} |
|||
}, |
|||
"WriteTo": [ |
|||
{ |
|||
"Name": "Console", |
|||
"Args": { |
|||
"restrictedToMinimumLevel": "Debug", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "Elasticsearch", |
|||
"Args": { |
|||
"nodeUris": "http://127.0.0.1:9200", |
|||
"indexFormat": "abp.dev.logging-{0:yyyy.MM.dd}", |
|||
"autoRegisterTemplate": true, |
|||
"autoRegisterTemplateVersion": "ESv7" |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
@ -0,0 +1,80 @@ |
|||
{ |
|||
"StringEncryption": { |
|||
"DefaultPassPhrase": "s46c5q55nxpeS8Ra", |
|||
"InitVectorBytes": "s83ng0abvd02js84", |
|||
"DefaultSalt": "sf&5)s3#" |
|||
}, |
|||
"AllowedHosts": "*", |
|||
"Serilog": { |
|||
"MinimumLevel": { |
|||
"Default": "Debug", |
|||
"Override": { |
|||
"Microsoft.EntityFrameworkCore": "Debug", |
|||
"System": "Information", |
|||
"Microsoft": "Information" |
|||
} |
|||
}, |
|||
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], |
|||
"WriteTo": [ |
|||
{ |
|||
"Name": "Console", |
|||
"Args": { |
|||
"initialMinimumLevel": "Verbose", |
|||
"standardErrorFromLevel": "Verbose", |
|||
"restrictedToMinimumLevel": "Verbose", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Debug-.log", |
|||
"restrictedToMinimumLevel": "Debug", |
|||
"rollingInterval": "Day", |
|||
"fileSizeLimitBytes": 5242880, |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Info-.log", |
|||
"restrictedToMinimumLevel": "Information", |
|||
"rollingInterval": "Day", |
|||
"fileSizeLimitBytes": 5242880, |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Warn-.log", |
|||
"restrictedToMinimumLevel": "Warning", |
|||
"rollingInterval": "Day", |
|||
"fileSizeLimitBytes": 5242880, |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Error-.log", |
|||
"restrictedToMinimumLevel": "Error", |
|||
"rollingInterval": "Day", |
|||
"fileSizeLimitBytes": 5242880, |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Fatal-.log", |
|||
"restrictedToMinimumLevel": "Fatal", |
|||
"rollingInterval": "Day", |
|||
"fileSizeLimitBytes": 5242880, |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.Controllers; |
|||
|
|||
public class HomeController : AbpController |
|||
{ |
|||
public IActionResult Index() |
|||
{ |
|||
return Redirect("/swagger/index.html"); |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
FROM mcr.microsoft.com/dotnet/aspnet:7.0 |
|||
LABEL maintainer="colin.in@foxmail.com" |
|||
WORKDIR /app |
|||
|
|||
COPY . /app |
|||
|
|||
## 设置上海时区.(Set your own time zone.) |
|||
#ENV TZ=Asia/Shanghai |
|||
#RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo '$TZ' > /etc/timezone |
|||
|
|||
## 解决连接SqlServer TLS版本过高问题.(The version of connection SqlServer TLS is too high.) |
|||
## 如果数据提供者是SqlServer,需要手动取消注释.(If the data provider is SqlServer, you need to manually uncomment it.) |
|||
##RUN sed -i 's/TLSv1.2/TLSv1.0/g' /etc/ssl/openssl.cnf |
|||
##RUN sed -i 's/TLSv1.2/TLSv1.0/g' /usr/lib/ssl/openssl.cnf |
|||
|
|||
EXPOSE 80/tcp |
|||
VOLUME [ "./app/Logs" ] |
|||
VOLUME [ "./app/Modules" ] |
|||
|
|||
ENTRYPOINT ["dotnet", "PackageName.CompanyName.ProjectName.HttpApi.Host.dll"] |
|||
@ -0,0 +1,81 @@ |
|||
using PackageName.CompanyName.ProjectName.EntityFrameworkCore; |
|||
using LINGYUN.Abp.Data.DbMigrator; |
|||
using LINGYUN.Abp.MultiTenancy; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.Logging; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.Uow; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.EventBus.Handlers; |
|||
|
|||
public class TenantSynchronizer : |
|||
IDistributedEventHandler<CreateEventData>, |
|||
ITransientDependency |
|||
{ |
|||
protected IDataSeeder DataSeeder { get; } |
|||
protected ICurrentTenant CurrentTenant { get; } |
|||
protected IDbSchemaMigrator DbSchemaMigrator { get; } |
|||
protected IUnitOfWorkManager UnitOfWorkManager { get; } |
|||
|
|||
protected ILogger<TenantSynchronizer> Logger { get; } |
|||
|
|||
public TenantSynchronizer( |
|||
IDataSeeder dataSeeder, |
|||
ICurrentTenant currentTenant, |
|||
IDbSchemaMigrator dbSchemaMigrator, |
|||
IUnitOfWorkManager unitOfWorkManager, |
|||
ILogger<TenantSynchronizer> logger) |
|||
{ |
|||
DataSeeder = dataSeeder; |
|||
CurrentTenant = currentTenant; |
|||
DbSchemaMigrator = dbSchemaMigrator; |
|||
UnitOfWorkManager = unitOfWorkManager; |
|||
|
|||
Logger = logger; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 租户创建之后需要预置种子数据
|
|||
/// </summary>
|
|||
/// <param name="eventData"></param>
|
|||
/// <returns></returns>
|
|||
public virtual async Task HandleEventAsync(CreateEventData eventData) |
|||
{ |
|||
using (var unitOfWork = UnitOfWorkManager.Begin()) |
|||
{ |
|||
using (CurrentTenant.Change(eventData.Id, eventData.Name)) |
|||
{ |
|||
Logger.LogInformation("Migrating the new tenant database with PackageName.CompanyName.ProjectName..."); |
|||
// 迁移租户数据
|
|||
await DbSchemaMigrator.MigrateAsync<ProjectNameDbContext>( |
|||
(connectionString, builder) => |
|||
{ |
|||
#if MySQL
|
|||
builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
|||
#elif SqlServer
|
|||
builder.UseSqlServer(connectionString); |
|||
#elif Sqlite
|
|||
builder.UseSqlite(connectionString); |
|||
#elif Oracle
|
|||
builder.UseOracle(connectionString); |
|||
#elif OracleDevart
|
|||
builder.UseOracle(connectionString); |
|||
#elif PostgreSql
|
|||
builder.UseNpgsql(connectionString); |
|||
#endif
|
|||
|
|||
return new ProjectNameDbContext(builder.Options); |
|||
}); |
|||
Logger.LogInformation("Migrated the new tenant database with PackageName.CompanyName.ProjectName..."); |
|||
|
|||
await DataSeeder.SeedAsync(new DataSeedContext(eventData.Id)); |
|||
|
|||
await unitOfWork.SaveChangesAsync(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,74 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk.Web"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net7.0</TargetFramework> |
|||
<RootNamespace>PackageName.CompanyName.ProjectName</RootNamespace> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="AgileConfig.Client" Version="$(AgileConfigClientPackageVersion)" /> |
|||
<PackageReference Include="DotNetCore.CAP.Dashboard" Version="$(DotNetCoreCAPPackageVersion)" /> |
|||
<PackageReference Include="DotNetCore.CAP.MySql" Version="$(DotNetCoreCAPPackageVersion)" Condition="'$(MySQL)'=='true'" /> |
|||
<PackageReference Include="DotNetCore.CAP.SqlServer" Version="$(DotNetCoreCAPPackageVersion)" Condition="'$(SqlServer)'=='true'" /> |
|||
<PackageReference Include="DotNetCore.CAP.Oracle" Version="$(DotNetCoreCAPPackageVersion)" Condition="'$(Oracle)'=='true'" /> |
|||
<PackageReference Include="DotNetCore.CAP.Oracle" Version="$(DotNetCoreCAPPackageVersion)" Condition="'$(OracleDevart)'=='true'" /> |
|||
<PackageReference Include="DotNetCore.CAP.PostgreSql" Version="$(DotNetCoreCAPPackageVersion)" Condition="'$(PostgreSql)'=='true'" /> |
|||
<PackageReference Include="DotNetCore.CAP.Sqlite" Version="$(DotNetCoreCAPPackageVersion)" Condition="'$(Sqlite)'=='true'" /> |
|||
<PackageReference Include="DotNetCore.CAP.RabbitMQ" Version="$(DotNetCoreCAPPackageVersion)" /> |
|||
<PackageReference Include="DotNetCore.CAP.OpenTelemetry" Version="$(DotNetCoreCAPPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.AspNetCore.Mvc.Wrapper" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.Dapr.Client.Wrapper" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.EventBus.CAP" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.ExceptionHandling.Emailing" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.Saas.EntityFrameworkCore" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.AuditLogging.Elasticsearch" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.Data.DbMigrator" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.Serilog.Enrichers.Application" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.Serilog.Enrichers.UniqueId" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.MultiTenancy" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.Localization.CultureMap" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.AspNetCore.Mvc.Localization" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.TextTemplating.EntityFrameworkCore" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="$(MicrosoftPackageVersion)"> |
|||
<PrivateAssets>all</PrivateAssets> |
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
|||
</PackageReference> |
|||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="$(MicrosoftPackageVersion)" /> |
|||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="$(MicrosoftPackageVersion)" /> |
|||
<PackageReference Include="DistributedLock.Redis" Version="$(DistributedLockRedisPackageVersion)" /> |
|||
<PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="$(OpenTelemetryExtensionsHostingPackageVersion)" /> |
|||
<PackageReference Include="OpenTelemetry.Exporter.Zipkin" Version="$(OpenTelemetryExporterZipkinPackageVersion)" /> |
|||
<PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" Version="$(OpenTelemetryInstrumentationAspNetCorePackageVersion)" /> |
|||
<PackageReference Include="OpenTelemetry.Instrumentation.Http" Version="$(OpenTelemetryInstrumentationHttpPackageVersion)" /> |
|||
<PackageReference Include="OpenTelemetry.Contrib.Instrumentation.EntityFrameworkCore" Version="$(OpenTelemetryContribInstrumentationEntityFrameworkCorePackageVersion)" /> |
|||
<PackageReference Include="Serilog.AspNetCore" Version="$(SerilogAspNetCorePackageVersion)" /> |
|||
<PackageReference Include="Serilog.Enrichers.Environment" Version="$(SerilogEnrichersEnvironmentPackageVersion)" /> |
|||
<PackageReference Include="Serilog.Enrichers.Assembly" Version="$(SerilogEnrichersAssemblyPackageVersion)" /> |
|||
<PackageReference Include="Serilog.Enrichers.Process" Version="$(SerilogEnrichersProcessPackageVersion)" /> |
|||
<PackageReference Include="Serilog.Enrichers.Thread" Version="$(SerilogEnrichersThreadPackageVersion)" /> |
|||
<PackageReference Include="Serilog.Settings.Configuration" Version="$(SerilogSettingsConfigurationPackageVersion)" /> |
|||
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="$(SerilogSinksElasticsearchPackageVersion)" /> |
|||
<PackageReference Include="Serilog.Sinks.File" Version="$(SerilogSinksFilePackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.MultiTenancy" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.OpenIddict.AspNetCore" Version="$(VoloAbpPackageVersion)" Condition="'$(OpenIddict)'=='true'" /> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="$(VoloAbpPackageVersion)" Condition="'$(IdentityServer4)'=='true'" /> |
|||
<PackageReference Include="Volo.Abp.Autofac" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.DistributedLocking" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.Swashbuckle" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.Http.Client.IdentityModel.Web" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\PackageName.CompanyName.ProjectName.Application\PackageName.CompanyName.ProjectName.Application.csproj" /> |
|||
<ProjectReference Include="..\..\src\PackageName.CompanyName.ProjectName.EntityFrameworkCore\PackageName.CompanyName.ProjectName.EntityFrameworkCore.csproj" /> |
|||
<ProjectReference Include="..\..\src\PackageName.CompanyName.ProjectName.HttpApi\PackageName.CompanyName.ProjectName.HttpApi.csproj" /> |
|||
<ProjectReference Include="..\..\src\PackageName.CompanyName.ProjectName.SettingManagement\PackageName.CompanyName.ProjectName.SettingManagement.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,61 @@ |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using Serilog; |
|||
using System; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.IO; |
|||
using Volo.Abp.Modularity.PlugIns; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
|
|||
public class Program |
|||
{ |
|||
public async static Task<int> Main(string[] args) |
|||
{ |
|||
try |
|||
{ |
|||
Log.Information("Starting web host."); |
|||
|
|||
var builder = WebApplication.CreateBuilder(args); |
|||
builder.Host.AddAppSettingsSecretsJson() |
|||
.UseAutofac() |
|||
.ConfigureAppConfiguration((context, config) => |
|||
{ |
|||
var configuration = config.Build(); |
|||
var agileConfigEnabled = configuration["AgileConfig:IsEnabled"]; |
|||
if (agileConfigEnabled.IsNullOrEmpty() || bool.Parse(agileConfigEnabled)) |
|||
{ |
|||
config.AddAgileConfig(new AgileConfig.Client.ConfigClient(configuration)); |
|||
} |
|||
}) |
|||
.UseSerilog((context, provider, config) => |
|||
{ |
|||
config.ReadFrom.Configuration(context.Configuration); |
|||
}); |
|||
await builder.AddApplicationAsync<ProjectNameHttpApiHostModule>(options => |
|||
{ |
|||
// 搜索 Modules 目录下所有文件作为插件
|
|||
// 取消显示引用所有其他项目的模块,改为通过插件的形式引用
|
|||
var pluginFolder = Path.Combine( |
|||
Directory.GetCurrentDirectory(), "Modules"); |
|||
DirectoryHelper.CreateIfNotExists(pluginFolder); |
|||
options.PlugInSources.AddFolder( |
|||
pluginFolder, |
|||
SearchOption.AllDirectories); |
|||
}); |
|||
var app = builder.Build(); |
|||
await app.InitializeApplicationAsync(); |
|||
await app.RunAsync(); |
|||
return 0; |
|||
} |
|||
finally |
|||
{ |
|||
Log.CloseAndFlush(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,361 @@ |
|||
using DotNetCore.CAP; |
|||
using LINGYUN.Abp.Dapr.Client.ClientProxying; |
|||
using LINGYUN.Abp.Dapr.Client.DynamicProxying; |
|||
using LINGYUN.Abp.ExceptionHandling; |
|||
using LINGYUN.Abp.ExceptionHandling.Emailing; |
|||
using LINGYUN.Abp.Localization.CultureMap; |
|||
using LINGYUN.Abp.Localization.Persistence; |
|||
using LINGYUN.Abp.Serilog.Enrichers.Application; |
|||
using LINGYUN.Abp.Serilog.Enrichers.UniqueId; |
|||
using LINGYUN.Abp.Wrapper; |
|||
using Medallion.Threading; |
|||
using Medallion.Threading.Redis; |
|||
using Microsoft.AspNetCore.Authentication.JwtBearer; |
|||
using Microsoft.AspNetCore.DataProtection; |
|||
using Microsoft.Extensions.Caching.StackExchangeRedis; |
|||
using Microsoft.Extensions.Configuration; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Options; |
|||
using Microsoft.OpenApi.Models; |
|||
using OpenTelemetry.Resources; |
|||
using OpenTelemetry.Trace; |
|||
using PackageName.CompanyName.ProjectName.Localization; |
|||
using StackExchange.Redis; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text.Encodings.Web; |
|||
using System.Text.Unicode; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Auditing; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.GlobalFeatures; |
|||
using Volo.Abp.Http.Client; |
|||
using Volo.Abp.Json; |
|||
using Volo.Abp.Json.SystemTextJson; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.Threading; |
|||
using Volo.Abp.VirtualFileSystem; |
|||
using static IdentityModel.ClaimComparer; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
|
|||
public partial class ProjectNameHttpApiHostModule |
|||
{ |
|||
protected const string ApplicationName = "ProjectName"; |
|||
private static readonly OneTimeRunner OneTimeRunner = new(); |
|||
|
|||
private void PreConfigureFeature() |
|||
{ |
|||
OneTimeRunner.Run(() => |
|||
{ |
|||
GlobalFeatureManager.Instance.Modules.Editions().EnableAll(); |
|||
}); |
|||
} |
|||
|
|||
private void PreConfigureApp() |
|||
{ |
|||
AbpSerilogEnrichersConsts.ApplicationName = ApplicationName; |
|||
|
|||
PreConfigure<AbpSerilogEnrichersUniqueIdOptions>(options => |
|||
{ |
|||
// 以开放端口区别
|
|||
options.SnowflakeIdOptions.WorkerId = 5; |
|||
options.SnowflakeIdOptions.WorkerIdBits = 5; |
|||
options.SnowflakeIdOptions.DatacenterId = 1; |
|||
}); |
|||
} |
|||
|
|||
private void PreConfigureCAP(IConfiguration configuration) |
|||
{ |
|||
PreConfigure<CapOptions>(options => |
|||
{ |
|||
options |
|||
#if MySQL
|
|||
.UseMySql(sqlOptions => |
|||
{ |
|||
configuration.GetSection("CAP:MySql").Bind(sqlOptions); |
|||
}) |
|||
#elif SqlServer
|
|||
.UseSqlServer(sqlOptions => |
|||
{ |
|||
configuration.GetSection("CAP:SqlServer").Bind(sqlOptions); |
|||
}) |
|||
#elif Sqlite
|
|||
.UseSqlite(sqlOptions => |
|||
{ |
|||
configuration.GetSection("CAP:Sqlite").Bind(sqlOptions); |
|||
}) |
|||
#elif Oracle || OracleDevart
|
|||
.UseOracle(sqlOptions => |
|||
{ |
|||
configuration.GetSection("CAP:Oracle").Bind(sqlOptions); |
|||
}) |
|||
#elif PostgreSql
|
|||
.UsePostgreSql(sqlOptions => |
|||
{ |
|||
configuration.GetSection("CAP:PostgreSql").Bind(sqlOptions); |
|||
}) |
|||
#endif
|
|||
.UseRabbitMQ(rabbitMQOptions => |
|||
{ |
|||
configuration.GetSection("CAP:RabbitMQ").Bind(rabbitMQOptions); |
|||
}) |
|||
.UseDashboard(); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureJsonSerializer() |
|||
{ |
|||
// 解决某些不支持类型的序列化
|
|||
Configure<AbpJsonOptions>(options => |
|||
{ |
|||
options.OutputDateTimeFormat = "yyyy-MM-dd HH:mm:ss"; |
|||
options.InputDateTimeFormats.AddIfNotContains("yyyy-MM-dd HH:mm:ss"); |
|||
options.InputDateTimeFormats.AddIfNotContains("yyyy-MM-ddTHH:mm:ss"); |
|||
}); |
|||
// 中文序列化的编码问题
|
|||
Configure<AbpSystemTextJsonSerializerOptions>(options => |
|||
{ |
|||
options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureDistributedLock(IServiceCollection services, IConfiguration configuration) |
|||
{ |
|||
var distributedLockEnabled = configuration["Redis:IsEnabled"]; |
|||
if (distributedLockEnabled.IsNullOrEmpty() || bool.Parse(distributedLockEnabled)) |
|||
{ |
|||
var redis = ConnectionMultiplexer.Connect(configuration["DistributedLock:Redis:Configuration"]); |
|||
services.AddSingleton<IDistributedLockProvider>(_ => new RedisDistributedSynchronizationProvider(redis.GetDatabase())); |
|||
} |
|||
} |
|||
|
|||
private void ConfigureOpenTelemetry(IServiceCollection services, IConfiguration configuration) |
|||
{ |
|||
var openTelemetryEnabled = configuration["OpenTelemetry:IsEnabled"]; |
|||
if (openTelemetryEnabled.IsNullOrEmpty() || bool.Parse(openTelemetryEnabled)) |
|||
{ |
|||
services.AddOpenTelemetryTracing(cfg => |
|||
{ |
|||
cfg.AddSource(ApplicationName) |
|||
.SetResourceBuilder( |
|||
ResourceBuilder.CreateDefault().AddService(ApplicationName)) |
|||
.AddHttpClientInstrumentation() |
|||
.AddAspNetCoreInstrumentation() |
|||
.AddEntityFrameworkCoreInstrumentation() |
|||
.AddCapInstrumentation() |
|||
.AddZipkinExporter(zipKinOptions => |
|||
{ |
|||
var endpoint = configuration["OpenTelemetry:ZipKin:Endpoint"]; |
|||
if (!endpoint.IsNullOrWhiteSpace()) |
|||
{ |
|||
zipKinOptions.Endpoint = new Uri(configuration["OpenTelemetry:ZipKin:Endpoint"]); |
|||
} |
|||
}); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
private void ConfigureExceptionHandling() |
|||
{ |
|||
// 自定义需要处理的异常
|
|||
Configure<AbpExceptionHandlingOptions>(options => |
|||
{ |
|||
// 加入需要处理的异常类型
|
|||
options.Handlers.Add<Volo.Abp.Data.AbpDbConcurrencyException>(); |
|||
options.Handlers.Add<AbpInitializationException>(); |
|||
options.Handlers.Add<OutOfMemoryException>(); |
|||
options.Handlers.Add<System.Data.Common.DbException>(); |
|||
options.Handlers.Add<Microsoft.EntityFrameworkCore.DbUpdateException>(); |
|||
options.Handlers.Add<System.Data.DBConcurrencyException>(); |
|||
}); |
|||
// 自定义需要发送邮件通知的异常类型
|
|||
Configure<AbpEmailExceptionHandlingOptions>(options => |
|||
{ |
|||
// 是否发送堆栈信息
|
|||
options.SendStackTrace = true; |
|||
// 未指定异常接收者的默认接收邮件
|
|||
// 指定自己的邮件地址
|
|||
}); |
|||
} |
|||
|
|||
private void ConfigureAuditing(IConfiguration configuration) |
|||
{ |
|||
Configure<AbpAuditingOptions>(options => |
|||
{ |
|||
options.ApplicationName = ApplicationName; |
|||
// 是否启用实体变更记录
|
|||
var allEntitiesSelectorIsEnabled = configuration["Auditing:AllEntitiesSelector"]; |
|||
if (allEntitiesSelectorIsEnabled.IsNullOrWhiteSpace() || |
|||
(bool.TryParse(allEntitiesSelectorIsEnabled, out var enabled) && enabled)) |
|||
{ |
|||
options.EntityHistorySelectors.AddAllEntities(); |
|||
} |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureCaching(IConfiguration configuration) |
|||
{ |
|||
Configure<AbpDistributedCacheOptions>(options => |
|||
{ |
|||
configuration.GetSection("DistributedCache").Bind(options); |
|||
}); |
|||
|
|||
Configure<RedisCacheOptions>(options => |
|||
{ |
|||
var redisConfig = ConfigurationOptions.Parse(options.Configuration); |
|||
options.ConfigurationOptions = redisConfig; |
|||
options.InstanceName = configuration["Redis:InstanceName"]; |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureVirtualFileSystem() |
|||
{ |
|||
Configure<AbpVirtualFileSystemOptions>(options => |
|||
{ |
|||
options.FileSets.AddEmbedded<ProjectNameHttpApiHostModule>("PackageName.CompanyName.ProjectName"); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureMultiTenancy(IConfiguration configuration) |
|||
{ |
|||
// 多租户
|
|||
Configure<AbpMultiTenancyOptions>(options => |
|||
{ |
|||
options.IsEnabled = true; |
|||
}); |
|||
|
|||
var tenantResolveCfg = configuration.GetSection("App:Domains"); |
|||
if (tenantResolveCfg.Exists()) |
|||
{ |
|||
Configure<AbpTenantResolveOptions>(options => |
|||
{ |
|||
var domains = tenantResolveCfg.Get<string[]>(); |
|||
foreach (var domain in domains) |
|||
{ |
|||
options.AddDomainTenantResolver(domain); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
|
|||
private void ConfigureSwagger(IServiceCollection services) |
|||
{ |
|||
// Swagger
|
|||
services.AddSwaggerGen( |
|||
options => |
|||
{ |
|||
options.SwaggerDoc("v1", new OpenApiInfo { Title = "ProjectName API", Version = "v1" }); |
|||
options.DocInclusionPredicate((docName, description) => true); |
|||
options.CustomSchemaIds(type => type.FullName); |
|||
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme |
|||
{ |
|||
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", |
|||
Name = "Authorization", |
|||
In = ParameterLocation.Header, |
|||
Scheme = "bearer", |
|||
Type = SecuritySchemeType.Http, |
|||
BearerFormat = "JWT" |
|||
}); |
|||
options.AddSecurityRequirement(new OpenApiSecurityRequirement |
|||
{ |
|||
{ |
|||
new OpenApiSecurityScheme |
|||
{ |
|||
Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" } |
|||
}, |
|||
new string[] { } |
|||
} |
|||
}); |
|||
options.OperationFilter<TenantHeaderParamter>(); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureLocalization() |
|||
{ |
|||
// 支持本地化语言类型
|
|||
Configure<AbpLocalizationOptions>(options => |
|||
{ |
|||
options.Languages.Add(new LanguageInfo("en", "en", "English")); |
|||
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文")); |
|||
}); |
|||
|
|||
Configure<AbpLocalizationPersistenceOptions>(options => |
|||
{ |
|||
// 持久化本地化资源
|
|||
options.SaveStaticLocalizationsToPersistence = true; |
|||
options.AddPersistenceResource<ProjectNameResource>(); |
|||
}); |
|||
|
|||
Configure<AbpLocalizationCultureMapOptions>(options => |
|||
{ |
|||
var zhHansCultureMapInfo = new CultureMapInfo |
|||
{ |
|||
TargetCulture = "zh-Hans", |
|||
SourceCultures = new string[] { "zh", "zh_CN", "zh-CN" } |
|||
}; |
|||
|
|||
options.CulturesMaps.Add(zhHansCultureMapInfo); |
|||
options.UiCulturesMaps.Add(zhHansCultureMapInfo); |
|||
}); |
|||
} |
|||
|
|||
private void ConfigureSecurity(IServiceCollection services, IConfiguration configuration, bool isDevelopment = false) |
|||
{ |
|||
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) |
|||
.AddJwtBearer(options => |
|||
{ |
|||
options.Authority = configuration["AuthServer:Authority"]; |
|||
options.Audience = configuration["AuthServer:ApiName"]; |
|||
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); |
|||
}); |
|||
|
|||
if (!isDevelopment) |
|||
{ |
|||
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); |
|||
services |
|||
.AddDataProtection() |
|||
.SetApplicationName("LINGYUN.Abp.Application") |
|||
.PersistKeysToStackExchangeRedis(redis, "LINGYUN.Abp.Application:DataProtection:Protection-Keys"); |
|||
} |
|||
} |
|||
|
|||
private void ConfigureWrapper() |
|||
{ |
|||
Configure<AbpWrapperOptions>(options => |
|||
{ |
|||
// 取消注释包装结果
|
|||
// options.IsEnabled = true;
|
|||
}); |
|||
|
|||
Configure<AbpHttpClientBuilderOptions>(options => |
|||
{ |
|||
// http服务间调用发送不需要包装结果的请求头
|
|||
options.ProxyClientBuildActions.Add( |
|||
(_, builder) => |
|||
{ |
|||
builder.ConfigureHttpClient((provider, client) => |
|||
{ |
|||
var wrapperOptions = provider.GetRequiredService<IOptions<AbpWrapperOptions>>(); |
|||
var wrapperHeader = wrapperOptions.Value.IsEnabled |
|||
? AbpHttpWrapConsts.AbpWrapResult |
|||
: AbpHttpWrapConsts.AbpDontWrapResult; |
|||
|
|||
client.DefaultRequestHeaders.TryAddWithoutValidation(wrapperHeader, "true"); |
|||
}); |
|||
}); |
|||
}); |
|||
|
|||
Configure<AbpDaprClientProxyOptions>(options => |
|||
{ |
|||
// dapr服务间调用发送不需要包装结果的请求头
|
|||
options.ProxyRequestActions.Add( |
|||
(appId, httpRequestMessage) => |
|||
{ |
|||
httpRequestMessage.Headers.TryAddWithoutValidation(AbpHttpWrapConsts.AbpDontWrapResult, "true"); |
|||
}); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,128 @@ |
|||
using LINGYUN.Abp.AspNetCore.Mvc.Wrapper; |
|||
using LINGYUN.Abp.AuditLogging.Elasticsearch; |
|||
using LINGYUN.Abp.EventBus.CAP; |
|||
using LINGYUN.Abp.ExceptionHandling.Emailing; |
|||
using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; |
|||
using LINGYUN.Abp.TextTemplating.EntityFrameworkCore; |
|||
using LINGYUN.Abp.Saas.EntityFrameworkCore; |
|||
using LINGYUN.Abp.Serilog.Enrichers.Application; |
|||
using LINGYUN.Abp.Serilog.Enrichers.UniqueId; |
|||
using Microsoft.AspNetCore.Builder; |
|||
using Microsoft.AspNetCore.Hosting; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
using PackageName.CompanyName.ProjectName.EntityFrameworkCore; |
|||
using PackageName.CompanyName.ProjectName.SettingManagement; |
|||
using Volo.Abp; |
|||
#if IdentityServer4
|
|||
using Volo.Abp.AspNetCore.Authentication.JwtBearer; |
|||
#elif OpenIddict
|
|||
using Volo.Abp.OpenIddict; |
|||
#endif
|
|||
using Volo.Abp.AspNetCore.MultiTenancy; |
|||
using Volo.Abp.AspNetCore.Serilog; |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.Caching.StackExchangeRedis; |
|||
using Volo.Abp.DistributedLocking; |
|||
using Volo.Abp.FeatureManagement.EntityFrameworkCore; |
|||
using Volo.Abp.Http.Client.IdentityModel.Web; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.PermissionManagement.EntityFrameworkCore; |
|||
using Volo.Abp.SettingManagement.EntityFrameworkCore; |
|||
using Volo.Abp.Swashbuckle; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpSerilogEnrichersApplicationModule), |
|||
typeof(AbpSerilogEnrichersUniqueIdModule), |
|||
typeof(AbpAuditLoggingElasticsearchModule), |
|||
typeof(AbpAspNetCoreSerilogModule), |
|||
typeof(ProjectNameApplicationModule), |
|||
typeof(ProjectNameHttpApiModule), |
|||
typeof(ProjectNameEntityFrameworkCoreModule), |
|||
typeof(ProjectNameSettingManagementModule), |
|||
typeof(AbpEmailingExceptionHandlingModule), |
|||
typeof(AbpCAPEventBusModule), |
|||
typeof(AbpHttpClientIdentityModelWebModule), |
|||
typeof(AbpAspNetCoreMultiTenancyModule), |
|||
typeof(AbpSaasEntityFrameworkCoreModule), |
|||
typeof(AbpFeatureManagementEntityFrameworkCoreModule), |
|||
typeof(AbpPermissionManagementEntityFrameworkCoreModule), |
|||
typeof(AbpSettingManagementEntityFrameworkCoreModule), |
|||
typeof(AbpLocalizationManagementEntityFrameworkCoreModule), |
|||
typeof(AbpTextTemplatingEntityFrameworkCoreModule), |
|||
#if IdentityServer4
|
|||
typeof(AbpAspNetCoreAuthenticationJwtBearerModule), |
|||
#elif OpenIddict
|
|||
typeof(AbpOpenIddictAspNetCoreModule), |
|||
#endif
|
|||
typeof(AbpCachingStackExchangeRedisModule), |
|||
typeof(AbpDistributedLockingModule), |
|||
typeof(AbpAspNetCoreMvcWrapperModule), |
|||
typeof(AbpSwashbuckleModule), |
|||
typeof(AbpAutofacModule) |
|||
)] |
|||
public partial class ProjectNameHttpApiHostModule : AbpModule |
|||
{ |
|||
public override void PreConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
var configuration = context.Services.GetConfiguration(); |
|||
|
|||
PreConfigureApp(); |
|||
PreConfigureFeature(); |
|||
PreConfigureCAP(configuration); |
|||
} |
|||
|
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
var hostingEnvironment = context.Services.GetHostingEnvironment(); |
|||
var configuration = context.Services.GetConfiguration(); |
|||
|
|||
ConfigureWrapper(); |
|||
ConfigureLocalization(); |
|||
ConfigureJsonSerializer(); |
|||
ConfigureExceptionHandling(); |
|||
ConfigureVirtualFileSystem(); |
|||
ConfigureCaching(configuration); |
|||
ConfigureAuditing(configuration); |
|||
ConfigureMultiTenancy(configuration); |
|||
ConfigureSwagger(context.Services); |
|||
ConfigureOpenTelemetry(context.Services, configuration); |
|||
ConfigureDistributedLock(context.Services, configuration); |
|||
ConfigureSecurity(context.Services, configuration, hostingEnvironment.IsDevelopment()); |
|||
} |
|||
|
|||
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|||
{ |
|||
var app = context.GetApplicationBuilder(); |
|||
var env = context.GetEnvironment(); |
|||
|
|||
app.UseMapRequestLocalization(); |
|||
app.UseCorrelationId(); |
|||
app.UseStaticFiles(); |
|||
app.UseRouting(); |
|||
app.UseCors(); |
|||
app.UseAuthentication(); |
|||
#if IdentityServer4
|
|||
app.UseJwtTokenMiddleware(); |
|||
#elif OpenIddict
|
|||
app.UseAbpOpenIddictValidation(); |
|||
#endif
|
|||
app.UseMultiTenancy(); |
|||
app.UseAuthorization(); |
|||
app.UseSwagger(); |
|||
app.UseAbpSwaggerUI(options => |
|||
{ |
|||
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support ProjectName API"); |
|||
|
|||
var configuration = context.GetConfiguration(); |
|||
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); |
|||
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); |
|||
options.OAuthScopes("ProjectName"); |
|||
}); |
|||
app.UseAuditing(); |
|||
app.UseAbpSerilogEnrichers(); |
|||
app.UseConfiguredEndpoints(); |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
{ |
|||
"iisSettings": { |
|||
"windowsAuthentication": false, |
|||
"anonymousAuthentication": true, |
|||
"iisExpress": { |
|||
"applicationUrl": "http://localhost:20890", |
|||
"sslPort": 0 |
|||
} |
|||
}, |
|||
"profiles": { |
|||
"PackageName.CompanyName.ProjectName.HttpApi.Host": { |
|||
"commandName": "Project", |
|||
"launchBrowser": false, |
|||
"dotnetRunMessages": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
}, |
|||
"applicationUrl": "http://127.0.0.1:5000" |
|||
}, |
|||
"IIS Express": { |
|||
"commandName": "IISExpress", |
|||
"launchBrowser": false, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
using Microsoft.Extensions.Options; |
|||
using Microsoft.OpenApi.Models; |
|||
using Swashbuckle.AspNetCore.SwaggerGen; |
|||
using System.Collections.Generic; |
|||
using Volo.Abp.MultiTenancy; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
|
|||
public class TenantHeaderParamter : IOperationFilter |
|||
{ |
|||
private readonly AbpMultiTenancyOptions _options; |
|||
public TenantHeaderParamter( |
|||
IOptions<AbpMultiTenancyOptions> options) |
|||
{ |
|||
_options = options.Value; |
|||
} |
|||
public void Apply(OpenApiOperation operation, OperationFilterContext context) |
|||
{ |
|||
if (_options.IsEnabled) |
|||
{ |
|||
operation.Parameters = operation.Parameters ?? new List<OpenApiParameter>(); |
|||
operation.Parameters.Add(new OpenApiParameter |
|||
{ |
|||
Name = TenantResolverConsts.DefaultTenantKey, |
|||
In = ParameterLocation.Header, |
|||
Description = "Tenant Id/Name", |
|||
Required = false |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,146 @@ |
|||
{ |
|||
"AgileConfig": { |
|||
"IsEnabled": false, |
|||
"env": "DEV", |
|||
"appId": "PackageName.CompanyName.ProjectName", |
|||
"secret": "1q2w3E*", |
|||
"nodes": "http://127.0.0.1:15000", |
|||
"name": "PackageName.CompanyName.ProjectName", |
|||
"tag": "PackageName.CompanyName.ProjectName" |
|||
}, |
|||
"Auditing": { |
|||
"AllEntitiesSelector": true |
|||
}, |
|||
"DistributedCache": { |
|||
"HideErrors": true, |
|||
"KeyPrefix": "LINGYUN.Abp.Application", |
|||
"GlobalCacheEntryOptions": { |
|||
"SlidingExpiration": "30:00:00", |
|||
"AbsoluteExpirationRelativeToNow": "60:00:00" |
|||
} |
|||
}, |
|||
"ConnectionStrings": { |
|||
"Default": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456", |
|||
"ProjectName": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456", |
|||
"AbpSaas": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456", |
|||
"AbpFeatureManagement": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456", |
|||
"AbpPermissionManagement": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456", |
|||
"AbpSettingManagement": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456", |
|||
"AbpLocalizationManagement": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456", |
|||
"AbpTextTemplating": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456" |
|||
}, |
|||
"DistributedLock": { |
|||
"IsEnabled": true, |
|||
"Redis": { |
|||
"Configuration": "127.0.0.1,defaultDatabase=15" |
|||
} |
|||
}, |
|||
"OpenTelemetry": { |
|||
"IsEnabled": true, |
|||
"ZipKin": { |
|||
"Endpoint": "http://127.0.0.1:9411/api/v2/spans" |
|||
} |
|||
}, |
|||
"RemoteServices": {}, |
|||
"IdentityClients": { |
|||
"InternalServiceClient": { |
|||
"Authority": "http://127.0.0.1:44385", |
|||
"RequireHttps": false, |
|||
"GrantType": "client_credentials", |
|||
"Scope": "lingyun-abp-application", |
|||
"ClientId": "InternalServiceClient", |
|||
"ClientSecret": "1q2w3E*" |
|||
} |
|||
}, |
|||
"CAP": { |
|||
"EventBus": { |
|||
"DefaultGroupName": "ProjectName", |
|||
"GroupNamePrefix": "Dev", |
|||
"Version": "v1", |
|||
"FailedRetryInterval": 300, |
|||
"FailedRetryCount": 10 |
|||
}, |
|||
"MySql": { |
|||
"TableNamePrefix": "ProjectName_cap", |
|||
"ConnectionString": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456" |
|||
}, |
|||
"SqlServer": { |
|||
"TableNamePrefix": "ProjectName_cap", |
|||
"ConnectionString": "Server=127.0.0.1;Database=ProjectName;User Id=root;Password=123456" |
|||
}, |
|||
"Sqlite": { |
|||
"TableNamePrefix": "ProjectName_cap", |
|||
"ConnectionString": "Data Source=./cap.db" |
|||
}, |
|||
"Oracle": { |
|||
"TableNamePrefix": "ProjectName_cap", |
|||
"ConnectionString": "Data Source=ProjectName;Integrated Security=yes;" |
|||
}, |
|||
"PostgreSql": { |
|||
"TableNamePrefix": "ProjectName_cap", |
|||
"ConnectionString": "Host=localhost;Port=5432;Database=ProjectName;User ID=root;Password=123456;" |
|||
}, |
|||
"RabbitMQ": { |
|||
"HostName": "127.0.0.1", |
|||
"Port": 5672, |
|||
"UserName": "admin", |
|||
"Password": "123456", |
|||
"ExchangeName": "LINGYUN.Abp.Application", |
|||
"VirtualHost": "/" |
|||
} |
|||
}, |
|||
"Redis": { |
|||
"Configuration": "127.0.0.1,defaultDatabase=10", |
|||
"InstanceName": "LINGYUN.Abp.Application" |
|||
}, |
|||
"AuthServer": { |
|||
"Authority": "http://127.0.0.1:44385/", |
|||
"ApiName": "lingyun-abp-application", |
|||
"RequireHttpsMetadata": false, |
|||
"SwaggerClientId": "InternalServiceClient", |
|||
"SwaggerClientSecret": "1q2w3E*" |
|||
}, |
|||
"Logging": { |
|||
"Serilog": { |
|||
"Elasticsearch": { |
|||
"IndexFormat": "abp.dev.logging-{0:yyyy.MM.dd}" |
|||
} |
|||
} |
|||
}, |
|||
"AuditLogging": { |
|||
"Elasticsearch": { |
|||
"IndexPrefix": "abp.dev.auditing" |
|||
} |
|||
}, |
|||
"Elasticsearch": { |
|||
"NodeUris": "http://127.0.0.1:9200" |
|||
}, |
|||
"Serilog": { |
|||
"MinimumLevel": { |
|||
"Default": "Debug", |
|||
"Override": { |
|||
"System": "Warning", |
|||
"Microsoft": "Warning", |
|||
"DotNetCore": "Debug" |
|||
} |
|||
}, |
|||
"WriteTo": [ |
|||
{ |
|||
"Name": "Console", |
|||
"Args": { |
|||
"restrictedToMinimumLevel": "Debug", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "Elasticsearch", |
|||
"Args": { |
|||
"nodeUris": "http://127.0.0.1:9200", |
|||
"indexFormat": "abp.dev.logging-{0:yyyy.MM.dd}", |
|||
"autoRegisterTemplate": true, |
|||
"autoRegisterTemplateVersion": "ESv7" |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
@ -0,0 +1,80 @@ |
|||
{ |
|||
"StringEncryption": { |
|||
"DefaultPassPhrase": "s46c5q55nxpeS8Ra", |
|||
"InitVectorBytes": "s83ng0abvd02js84", |
|||
"DefaultSalt": "sf&5)s3#" |
|||
}, |
|||
"AllowedHosts": "*", |
|||
"Serilog": { |
|||
"MinimumLevel": { |
|||
"Default": "Debug", |
|||
"Override": { |
|||
"Microsoft.EntityFrameworkCore": "Debug", |
|||
"System": "Information", |
|||
"Microsoft": "Information" |
|||
} |
|||
}, |
|||
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], |
|||
"WriteTo": [ |
|||
{ |
|||
"Name": "Console", |
|||
"Args": { |
|||
"initialMinimumLevel": "Verbose", |
|||
"standardErrorFromLevel": "Verbose", |
|||
"restrictedToMinimumLevel": "Verbose", |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Debug-.log", |
|||
"restrictedToMinimumLevel": "Debug", |
|||
"rollingInterval": "Day", |
|||
"fileSizeLimitBytes": 5242880, |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Info-.log", |
|||
"restrictedToMinimumLevel": "Information", |
|||
"rollingInterval": "Day", |
|||
"fileSizeLimitBytes": 5242880, |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Warn-.log", |
|||
"restrictedToMinimumLevel": "Warning", |
|||
"rollingInterval": "Day", |
|||
"fileSizeLimitBytes": 5242880, |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Error-.log", |
|||
"restrictedToMinimumLevel": "Error", |
|||
"rollingInterval": "Day", |
|||
"fileSizeLimitBytes": 5242880, |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
}, |
|||
{ |
|||
"Name": "File", |
|||
"Args": { |
|||
"path": "Logs/Fatal-.log", |
|||
"restrictedToMinimumLevel": "Fatal", |
|||
"rollingInterval": "Day", |
|||
"fileSizeLimitBytes": 5242880, |
|||
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
|||
} |
|||
} |
|||
] |
|||
} |
|||
} |
|||
@ -0,0 +1 @@ |
|||
dapr run --app-id ProjectName --app-port 5000 -H 3500 -- dotnet run --no-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,22 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="../../common.props" /> |
|||
<Import Project="../../configureawait.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Ddd.Application.Contracts" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.Authorization" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.Features" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.Dynamic.Queryable.Application.Contracts" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\PackageName.CompanyName.ProjectName.Domain.Shared\PackageName.CompanyName.ProjectName.Domain.Shared.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,22 @@ |
|||
using PackageName.CompanyName.ProjectName.Localization; |
|||
using Volo.Abp.Authorization.Permissions; |
|||
using Volo.Abp.Localization; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.Authorization; |
|||
|
|||
public class ProjectNamePermissionDefinitionProvider : PermissionDefinitionProvider |
|||
{ |
|||
public override void Define(IPermissionDefinitionContext context) |
|||
{ |
|||
var group = context.AddGroup(ProjectNamePermissions.GroupName, L("Permission:ProjectName")); |
|||
|
|||
group.AddPermission( |
|||
ProjectNamePermissions.ManageSettings, |
|||
L("Permission:ManageSettings")); |
|||
} |
|||
|
|||
private static LocalizableString L(string name) |
|||
{ |
|||
return LocalizableString.Create<ProjectNameResource>(name); |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
namespace PackageName.CompanyName.ProjectName.Authorization; |
|||
|
|||
public static class ProjectNamePermissions |
|||
{ |
|||
public const string GroupName = "ProjectName"; |
|||
|
|||
public const string ManageSettings = GroupName + ".ManageSettings"; |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using PackageName.CompanyName.ProjectName.Localization; |
|||
using Volo.Abp.Features; |
|||
using Volo.Abp.Localization; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.Features; |
|||
|
|||
public class ProjectNameFeatureDefinitionProvider : FeatureDefinitionProvider |
|||
{ |
|||
public override void Define(IFeatureDefinitionContext context) |
|||
{ |
|||
var group = context.AddGroup(ProjectNameFeatureNames.GroupName, L("Features:ProjectName")); |
|||
} |
|||
|
|||
private static ILocalizableString L(string name) |
|||
{ |
|||
return LocalizableString.Create<ProjectNameResource>(name); |
|||
} |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
namespace PackageName.CompanyName.ProjectName.Features; |
|||
|
|||
public static class ProjectNameFeatureNames |
|||
{ |
|||
public const string GroupName = "ProjectName"; |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using LINGYUN.Abp.Dynamic.Queryable; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
/// <summary>
|
|||
/// 提供动态查询接口定义
|
|||
/// </summary>
|
|||
/// <typeparam name="TEntityDto">实体dto类型</typeparam>
|
|||
public interface IProjectNameDynamicQueryableAppService<TEntityDto> : IDynamicQueryableAppService<TEntityDto> |
|||
{ |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using LINGYUN.Abp.Dynamic.Queryable; |
|||
using Volo.Abp.Application; |
|||
using Volo.Abp.Authorization; |
|||
using Volo.Abp.Features; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpFeaturesModule), |
|||
typeof(AbpAuthorizationModule), |
|||
typeof(AbpDddApplicationContractsModule), |
|||
typeof(AbpDynamicQueryableApplicationContractsModule), |
|||
typeof(ProjectNameDomainSharedModule))] |
|||
public class ProjectNameApplicationContractsModule : AbpModule |
|||
{ |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace PackageName.CompanyName.ProjectName; |
|||
|
|||
public static class ProjectNameRemoteServiceConsts |
|||
{ |
|||
public const string RemoteServiceName = "ProjectName"; |
|||
public const string ModuleName = "ProjectName"; |
|||
} |
|||
@ -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,21 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="../../common.props" /> |
|||
<Import Project="../../configureawait.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.1</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Ddd.Application" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.Dynamic.Queryable.Application" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\PackageName.CompanyName.ProjectName.Application.Contracts\PackageName.CompanyName.ProjectName.Application.Contracts.csproj" /> |
|||
<ProjectReference Include="..\PackageName.CompanyName.ProjectName.Domain\PackageName.CompanyName.ProjectName.Domain.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,13 @@ |
|||
using PackageName.CompanyName.ProjectName.Localization; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
|
|||
public abstract class ProjectNameAppServiceBase : ApplicationService |
|||
{ |
|||
protected ProjectNameAppServiceBase() |
|||
{ |
|||
LocalizationResource = typeof(ProjectNameResource); |
|||
ObjectMapperContext = typeof(ProjectNameApplicationModule); |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using AutoMapper; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
|
|||
public class ProjectNameApplicationMapperProfile : Profile |
|||
{ |
|||
public ProjectNameApplicationMapperProfile() |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
using LINGYUN.Abp.Dynamic.Queryable; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Application; |
|||
using Volo.Abp.Authorization; |
|||
using Volo.Abp.AutoMapper; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpAuthorizationModule), |
|||
typeof(AbpDddApplicationModule), |
|||
typeof(ProjectNameDomainModule), |
|||
typeof(ProjectNameApplicationContractsModule), |
|||
typeof(AbpDynamicQueryableApplicationModule))] |
|||
public class ProjectNameApplicationModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddAutoMapperObjectMapper<ProjectNameApplicationModule>(); |
|||
|
|||
Configure<AbpAutoMapperOptions>(options => |
|||
{ |
|||
options.AddProfile<ProjectNameApplicationMapperProfile>(validate: true); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
using LINGYUN.Abp.Dynamic.Queryable; |
|||
using PackageName.CompanyName.ProjectName.Localization; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
/// <summary>
|
|||
/// 提供动态查询接口实现
|
|||
/// </summary>
|
|||
/// <typeparam name="TEntity">实体类型</typeparam>
|
|||
/// <typeparam name="TEntityDto">实体dto类型</typeparam>
|
|||
public abstract class ProjectNameDynamicQueryableAppServiceBase<TEntity, TEntityDto> : |
|||
DynamicQueryableAppService<TEntity, TEntityDto>, |
|||
IProjectNameDynamicQueryableAppService<TEntityDto> |
|||
{ |
|||
protected ProjectNameDynamicQueryableAppServiceBase() |
|||
{ |
|||
LocalizationResource = typeof(ProjectNameResource); |
|||
ObjectMapperContext = typeof(ProjectNameApplicationModule); |
|||
} |
|||
} |
|||
@ -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,19 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="../../common.props" /> |
|||
<Import Project="../../configureawait.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net7.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="LINGYUN.Abp.Dapr.Client" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\PackageName.CompanyName.ProjectName.Application.Contracts\PackageName.CompanyName.ProjectName.Application.Contracts.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,18 @@ |
|||
using LINGYUN.Abp.Dapr.Client; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpDaprClientModule), |
|||
typeof(ProjectNameApplicationContractsModule))] |
|||
public class ProjectNameDaprClientModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddDaprClientProxies( |
|||
typeof(ProjectNameApplicationContractsModule).Assembly, |
|||
ProjectNameRemoteServiceConsts.RemoteServiceName); |
|||
} |
|||
} |
|||
@ -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,25 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="../../common.props" /> |
|||
<Import Project="../../configureawait.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Remove="PackageName\CompanyName\ProjectName\Localization\Resources\*.json" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<EmbeddedResource Include="PackageName\CompanyName\ProjectName\Localization\Resources\*.json" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Auditing" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.EventBus" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.Localization" Version="$(VoloAbpPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,8 @@ |
|||
using Volo.Abp.Localization; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.Localization; |
|||
|
|||
[LocalizationResourceName("ProjectName")] |
|||
public class ProjectNameResource |
|||
{ |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
{ |
|||
"culture": "en", |
|||
"texts": { |
|||
"Features:ProjectName": "ProjectName", |
|||
"Permission:ProjectName": "ProjectName", |
|||
"Permission:ManageSettings": "Manage Settings" |
|||
} |
|||
} |
|||
@ -0,0 +1,8 @@ |
|||
{ |
|||
"culture": "zh-Hans", |
|||
"texts": { |
|||
"Features:ProjectName": "ProjectName", |
|||
"Permission:ProjectName": "ProjectName", |
|||
"Permission:ManageSettings": "管理设置" |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using System; |
|||
using Volo.Abp.ObjectExtending.Modularity; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.ObjectExtending; |
|||
|
|||
public class ProjectNameModuleExtensionConfiguration : ModuleExtensionConfiguration |
|||
{ |
|||
public ProjectNameModuleExtensionConfiguration ConfigureProjectName( |
|||
Action<EntityExtensionConfiguration> configureAction) |
|||
{ |
|||
return this.ConfigureEntity( |
|||
ProjectNameModuleExtensionConsts.EntityNames.Entity, |
|||
configureAction |
|||
); |
|||
} |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Volo.Abp.ObjectExtending.Modularity; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.ObjectExtending; |
|||
|
|||
public static class ProjectNameModuleExtensionConfigurationDictionaryExtensions |
|||
{ |
|||
public static ModuleExtensionConfigurationDictionary ConfigureProjectName( |
|||
this ModuleExtensionConfigurationDictionary modules, |
|||
Action<ProjectNameModuleExtensionConfiguration> configureAction) |
|||
{ |
|||
return modules.ConfigureModule( |
|||
ProjectNameModuleExtensionConsts.ModuleName, |
|||
configureAction |
|||
); |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
namespace PackageName.CompanyName.ProjectName.ObjectExtending; |
|||
|
|||
public static class ProjectNameModuleExtensionConsts |
|||
{ |
|||
public const string ModuleName = "ProjectName"; |
|||
|
|||
public static class EntityNames |
|||
{ |
|||
public const string Entity = "Entity"; |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
using PackageName.CompanyName.ProjectName.Localization; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.Localization.ExceptionHandling; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.VirtualFileSystem; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpLocalizationModule))] |
|||
public class ProjectNameDomainSharedModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpVirtualFileSystemOptions>(options => |
|||
{ |
|||
options.FileSets.AddEmbedded<ProjectNameDomainSharedModule>(); |
|||
}); |
|||
|
|||
Configure<AbpLocalizationOptions>(options => |
|||
{ |
|||
options.Resources |
|||
.Add<ProjectNameResource>() |
|||
.AddVirtualJson("/PackageName/CompanyName/ProjectName/Localization/Resources"); |
|||
}); |
|||
|
|||
Configure<AbpExceptionLocalizationOptions>(options => |
|||
{ |
|||
options.MapCodeNamespace(ProjectNameErrorCodes.Namespace, typeof(ProjectNameResource)); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
namespace PackageName.CompanyName.ProjectName; |
|||
|
|||
public static class ProjectNameErrorCodes |
|||
{ |
|||
public const string Namespace = "ProjectName"; |
|||
} |
|||
@ -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,21 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="../../common.props" /> |
|||
<Import Project="../../configureawait.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.1</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.AutoMapper" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.Caching" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="$(VoloAbpPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\PackageName.CompanyName.ProjectName.Domain.Shared\PackageName.CompanyName.ProjectName.Domain.Shared.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,40 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Entities; |
|||
using Volo.Abp.Specifications; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
/// <summary>
|
|||
/// 实现接口支持规约化查询
|
|||
/// </summary>
|
|||
/// <typeparam name="TEntity">实体类型</typeparam>
|
|||
/// <typeparam name="TKey">实体主键类型</typeparam>
|
|||
public interface IProjectNameSpecificationSupport<TEntity, TKey> |
|||
where TEntity : class, IEntity<TKey> |
|||
{ |
|||
/// <summary>
|
|||
/// 获取过滤后的实体数量
|
|||
/// </summary>
|
|||
/// <param name="specification"></param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<int> GetCountAsync( |
|||
ISpecification<TEntity> specification, |
|||
CancellationToken cancellationToken = default); |
|||
/// <summary>
|
|||
/// 获取过滤后的实体列表
|
|||
/// </summary>
|
|||
/// <param name="specification"></param>
|
|||
/// <param name="sorting"></param>
|
|||
/// <param name="maxResultCount"></param>
|
|||
/// <param name="skipCount"></param>
|
|||
/// <param name="cancellationToken"></param>
|
|||
/// <returns></returns>
|
|||
Task<List<TEntity>> GetListAsync( |
|||
ISpecification<TEntity> specification, |
|||
string sorting = nameof(IEntity<TKey>.Id), |
|||
int maxResultCount = 10, |
|||
int skipCount = 0, |
|||
CancellationToken cancellationToken = default); |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
namespace PackageName.CompanyName.ProjectName; |
|||
|
|||
public static class ProjectNameDbProperties |
|||
{ |
|||
public static string DbTablePrefix { get; set; } = "ProjectName_"; |
|||
|
|||
public static string DbSchema { get; set; } = null; |
|||
|
|||
|
|||
public const string ConnectionStringName = "ProjectName"; |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using AutoMapper; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
|
|||
public class ProjectNameDomainMapperProfile : Profile |
|||
{ |
|||
public ProjectNameDomainMapperProfile() |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,43 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using PackageName.CompanyName.ProjectName.ObjectExtending; |
|||
using Volo.Abp.AutoMapper; |
|||
using Volo.Abp.Domain.Entities.Events.Distributed; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.ObjectExtending.Modularity; |
|||
using Volo.Abp.Threading; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpAutoMapperModule), |
|||
typeof(ProjectNameDomainSharedModule))] |
|||
public class ProjectNameDomainModule : AbpModule |
|||
{ |
|||
private static readonly OneTimeRunner OneTimeRunner = new(); |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddAutoMapperObjectMapper<ProjectNameDomainModule>(); |
|||
|
|||
Configure<AbpAutoMapperOptions>(options => |
|||
{ |
|||
options.AddProfile<ProjectNameDomainMapperProfile>(validate: true); |
|||
}); |
|||
|
|||
Configure<AbpDistributedEntityEventOptions>(options => |
|||
{ |
|||
}); |
|||
} |
|||
|
|||
public override void PostConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
OneTimeRunner.Run(() => |
|||
{ |
|||
// 扩展实体配置
|
|||
//ModuleExtensionConfigurationHelper.ApplyEntityConfigurationToEntity(
|
|||
// ProjectNameModuleExtensionConsts.ModuleName,
|
|||
// ProjectNameModuleExtensionConsts.EntityNames.Entity,
|
|||
// typeof(Entity)
|
|||
//);
|
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
using Volo.Abp.Settings; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.Settings |
|||
{ |
|||
public class ProjectNameSettingDefinitionProvider : SettingDefinitionProvider |
|||
{ |
|||
public override void Define(ISettingDefinitionContext context) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace PackageName.CompanyName.ProjectName.Settings |
|||
{ |
|||
public static class ProjectNameSettings |
|||
{ |
|||
public const string GroupName = "ProjectName"; |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
using Volo.Abp.Specifications; |
|||
|
|||
namespace System.Linq.Expressions; |
|||
|
|||
internal static class ExpressionFuncExtensions |
|||
{ |
|||
public static Expression<Func<T, bool>> AndIf<T>( |
|||
this Expression<Func<T, bool>> first, |
|||
bool condition, |
|||
Expression<Func<T, bool>> second) |
|||
{ |
|||
if (condition) |
|||
{ |
|||
return ExpressionFuncExtender.And(first, second); |
|||
} |
|||
|
|||
return first; |
|||
} |
|||
|
|||
public static Expression<Func<T, bool>> OrIf<T>( |
|||
this Expression<Func<T, bool>> first, |
|||
bool condition, |
|||
Expression<Func<T, bool>> second) |
|||
{ |
|||
if (condition) |
|||
{ |
|||
return ExpressionFuncExtender.Or(first, second); |
|||
} |
|||
|
|||
return first; |
|||
} |
|||
} |
|||
@ -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,31 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="../../common.props" /> |
|||
<Import Project="../../configureawait.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net7.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="$(MicrosoftEntityFrameworkCorePackageVersion)"> |
|||
<PrivateAssets>all</PrivateAssets> |
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
|||
</PackageReference> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySql" Version="$(VoloAbpPackageVersion)" Condition="'$(MySQL)'=='true'" /> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.SqlServer" Version="$(VoloAbpPackageVersion)" Condition="'$(SqlServer)'=='true'" /> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.Sqlite" Version="$(VoloAbpPackageVersion)" Condition="'$(Sqlite)'=='true'" /> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.Oracle" Version="$(VoloAbpPackageVersion)" Condition="'$(Oracle)'=='true'" /> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.Oracle.Devart" Version="$(VoloAbpPackageVersion)" Condition="'$(OracleDevart)'=='true'" /> |
|||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.PostgreSql" Version="$(VoloAbpPackageVersion)" Condition="'$(PostgreSql)'=='true'" /> |
|||
<PackageReference Include="LINGYUN.Abp.Data.DbMigrator" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.Saas.EntityFrameworkCore" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\PackageName.CompanyName.ProjectName.Domain\PackageName.CompanyName.ProjectName.Domain.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,60 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Linq.Dynamic.Core; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Domain.Entities; |
|||
using Volo.Abp.Domain.Repositories.EntityFrameworkCore; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.Specifications; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.EntityFrameworkCore; |
|||
/// <summary>
|
|||
/// 实现仓储提供规约化查询
|
|||
/// </summary>
|
|||
/// <typeparam name="TEntity">实体类型</typeparam>
|
|||
/// <typeparam name="TKey">实体主键类型</typeparam>
|
|||
public abstract class EfCoreSpecificationSupportRepository<TEntity, TKey> : |
|||
EfCoreRepository<IProjectNameDbContext, TEntity, TKey>, |
|||
IProjectNameSpecificationSupport<TEntity, TKey> |
|||
where TEntity : class, IEntity<TKey> |
|||
{ |
|||
protected EfCoreSpecificationSupportRepository( |
|||
IDbContextProvider<IProjectNameDbContext> dbContextProvider) : base(dbContextProvider) |
|||
{ |
|||
} |
|||
|
|||
public async virtual Task<int> GetCountAsync( |
|||
ISpecification<TEntity> specification, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
return await (await GetDbSetAsync()) |
|||
.Where(specification.ToExpression()) |
|||
.CountAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
|
|||
public async virtual Task<List<TEntity>> GetListAsync( |
|||
ISpecification<TEntity> specification, |
|||
string sorting = nameof(IEntity<TKey>.Id), |
|||
int maxResultCount = 10, |
|||
int skipCount = 0, |
|||
CancellationToken cancellationToken = default) |
|||
{ |
|||
return await (await GetDbSetAsync()) |
|||
.Where(specification.ToExpression()) |
|||
.OrderBy(GetSortingOrDefault(sorting)) |
|||
.PageBy(skipCount, maxResultCount) |
|||
.ToListAsync(GetCancellationToken(cancellationToken)); |
|||
} |
|||
|
|||
protected virtual string GetSortingOrDefault(string sorting = nameof(IEntity<TKey>.Id)) |
|||
{ |
|||
if (sorting.IsNullOrWhiteSpace()) |
|||
{ |
|||
return nameof(IEntity<TKey>.Id); |
|||
} |
|||
return sorting; |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.EntityFrameworkCore; |
|||
|
|||
[ConnectionStringName(ProjectNameDbProperties.ConnectionStringName)] |
|||
public interface IProjectNameDbContext : IEfCoreDbContext |
|||
{ |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.EntityFrameworkCore; |
|||
|
|||
[ConnectionStringName(ProjectNameDbProperties.ConnectionStringName)] |
|||
public class ProjectNameDbContext : AbpDbContext<ProjectNameDbContext>, IProjectNameDbContext |
|||
{ |
|||
public ProjectNameDbContext( |
|||
DbContextOptions<ProjectNameDbContext> options) : base(options) |
|||
{ |
|||
} |
|||
|
|||
protected override void OnModelCreating(ModelBuilder modelBuilder) |
|||
{ |
|||
base.OnModelCreating(modelBuilder); |
|||
|
|||
modelBuilder.ConfigureProjectName(); |
|||
} |
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.EntityFrameworkCore.Design; |
|||
using Microsoft.Extensions.Configuration; |
|||
using System.IO; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.EntityFrameworkCore; |
|||
public class ProjectNameDbContextFactory : IDesignTimeDbContextFactory<ProjectNameDbContext> |
|||
{ |
|||
public ProjectNameDbContext CreateDbContext(string[] args) |
|||
{ |
|||
var configuration = BuildConfiguration(); |
|||
var connectionString = configuration.GetConnectionString("ProjectName"); |
|||
|
|||
DbContextOptionsBuilder<ProjectNameDbContext> builder = null; |
|||
|
|||
#if MySQL
|
|||
builder = new DbContextOptionsBuilder<ProjectNameDbContext>() |
|||
.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
|||
#elif SqlServer
|
|||
builder = new DbContextOptionsBuilder<ProjectNameDbContext>() |
|||
.UseSqlServer(connectionString); |
|||
#elif Sqlite
|
|||
builder = new DbContextOptionsBuilder<ProjectNameDbContext>() |
|||
.UseSqlite(connectionString); |
|||
#elif Oracle
|
|||
builder = new DbContextOptionsBuilder<ProjectNameDbContext>() |
|||
.UseOracle(connectionString); |
|||
#elif OracleDevart
|
|||
builder = (DbContextOptionsBuilder<ProjectNameDbContext>) new DbContextOptionsBuilder<ProjectNameDbContext>() |
|||
.UseOracle(connectionString); |
|||
#elif PostgreSql
|
|||
builder = new DbContextOptionsBuilder<ProjectNameDbContext>() |
|||
.UseNpgsql(connectionString); |
|||
#endif
|
|||
|
|||
return new ProjectNameDbContext(builder!.Options); |
|||
} |
|||
|
|||
private static IConfigurationRoot BuildConfiguration() |
|||
{ |
|||
var builder = new ConfigurationBuilder() |
|||
.SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../PackageName.CompanyName.ProjectName.DbMigrator/")) |
|||
.AddJsonFile("appsettings.json", optional: false) |
|||
.AddJsonFile("appsettings.Development.json", optional: true); |
|||
|
|||
return builder.Build(); |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,21 @@ |
|||
using Microsoft.EntityFrameworkCore; |
|||
using System; |
|||
using Volo.Abp; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.EntityFrameworkCore; |
|||
|
|||
public static class ProjectNameDbContextModelCreatingExtensions |
|||
{ |
|||
public static void ConfigureProjectName( |
|||
this ModelBuilder builder, |
|||
Action<ProjectNameModelBuilderConfigurationOptions> optionsAction = null) |
|||
{ |
|||
Check.NotNull(builder, nameof(builder)); |
|||
|
|||
var options = new ProjectNameModelBuilderConfigurationOptions( |
|||
ProjectNameDbProperties.DbTablePrefix, |
|||
ProjectNameDbProperties.DbSchema |
|||
); |
|||
optionsAction?.Invoke(options); |
|||
} |
|||
} |
|||
@ -0,0 +1,234 @@ |
|||
using LINGYUN.Abp.Data.DbMigrator; |
|||
using LINGYUN.Abp.Saas.Tenants; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.Extensions.Logging; |
|||
using Microsoft.Extensions.Logging.Abstractions; |
|||
using PackageName.CompanyName.ProjectName.EntityFrameworkCore; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Diagnostics; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Runtime.InteropServices; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Data; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.MultiTenancy; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.DbMigrator.EntityFrameworkCore; |
|||
|
|||
public class ProjectNameDbMigrationService : ITransientDependency |
|||
{ |
|||
public ILogger<ProjectNameDbMigrationService> Logger { get; set; } |
|||
|
|||
private readonly IDataSeeder _dataSeeder; |
|||
private readonly IDbSchemaMigrator _dbSchemaMigrator; |
|||
private readonly ITenantRepository _tenantRepository; |
|||
private readonly ICurrentTenant _currentTenant; |
|||
|
|||
public ProjectNameDbMigrationService( |
|||
IDataSeeder dataSeeder, |
|||
IDbSchemaMigrator dbSchemaMigrator, |
|||
ITenantRepository tenantRepository, |
|||
ICurrentTenant currentTenant) |
|||
{ |
|||
_dataSeeder = dataSeeder; |
|||
_dbSchemaMigrator = dbSchemaMigrator; |
|||
_tenantRepository = tenantRepository; |
|||
_currentTenant = currentTenant; |
|||
|
|||
Logger = NullLogger<ProjectNameDbMigrationService>.Instance; |
|||
} |
|||
|
|||
public async Task MigrateAsync() |
|||
{ |
|||
var initialMigrationAdded = AddInitialMigrationIfNotExist(); |
|||
|
|||
if (initialMigrationAdded) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
Logger.LogInformation("Started database migrations..."); |
|||
|
|||
await MigrateDatabaseSchemaAsync(); |
|||
await SeedDataAsync(); |
|||
|
|||
Logger.LogInformation($"Successfully completed host database migrations."); |
|||
|
|||
var tenants = await _tenantRepository.GetListAsync(includeDetails: true); |
|||
|
|||
var migratedDatabaseSchemas = new HashSet<string>(); |
|||
foreach (var tenant in tenants) |
|||
{ |
|||
using (_currentTenant.Change(tenant.Id)) |
|||
{ |
|||
if (tenant.ConnectionStrings.Any()) |
|||
{ |
|||
var tenantConnectionStrings = tenant.ConnectionStrings |
|||
.Select(x => x.Value) |
|||
.ToList(); |
|||
|
|||
if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) |
|||
{ |
|||
await MigrateDatabaseSchemaAsync(tenant); |
|||
|
|||
migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); |
|||
} |
|||
} |
|||
|
|||
await SeedDataAsync(tenant); |
|||
} |
|||
|
|||
Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); |
|||
} |
|||
|
|||
Logger.LogInformation("Successfully completed all database migrations."); |
|||
Logger.LogInformation("You can safely end this process..."); |
|||
} |
|||
|
|||
private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null) |
|||
{ |
|||
Logger.LogInformation($"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); |
|||
// 迁移租户数据
|
|||
await _dbSchemaMigrator.MigrateAsync<ProjectNameDbContext>( |
|||
(connectionString, builder) => |
|||
{ |
|||
#if MySQL
|
|||
builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
|||
#elif SqlServer
|
|||
builder.UseSqlServer(connectionString); |
|||
#elif Sqlite
|
|||
builder.UseSqlite(connectionString); |
|||
#elif Oracle
|
|||
builder.UseOracle(connectionString); |
|||
#elif OracleDevart
|
|||
builder.UseOracle(connectionString); |
|||
#elif PostgreSql
|
|||
builder.UseNpgsql(connectionString); |
|||
#endif
|
|||
|
|||
return new ProjectNameDbContext(builder.Options); |
|||
}); |
|||
} |
|||
|
|||
private async Task SeedDataAsync(Tenant? tenant = null) |
|||
{ |
|||
Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); |
|||
|
|||
await _dataSeeder.SeedAsync(tenant?.Id); |
|||
} |
|||
|
|||
private bool AddInitialMigrationIfNotExist() |
|||
{ |
|||
try |
|||
{ |
|||
if (!DbMigrationsProjectExists()) |
|||
{ |
|||
return false; |
|||
} |
|||
} |
|||
catch (Exception) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
try |
|||
{ |
|||
if (!MigrationsFolderExists()) |
|||
{ |
|||
AddInitialMigration(); |
|||
return true; |
|||
} |
|||
else |
|||
{ |
|||
return false; |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
private bool DbMigrationsProjectExists() |
|||
{ |
|||
return Directory.Exists(GetEntityFrameworkCoreProjectFolderPath()); |
|||
} |
|||
|
|||
private bool MigrationsFolderExists() |
|||
{ |
|||
var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); |
|||
|
|||
return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); |
|||
} |
|||
|
|||
private void AddInitialMigration() |
|||
{ |
|||
Logger.LogInformation("Creating initial migration..."); |
|||
|
|||
string argumentPrefix; |
|||
string fileName; |
|||
|
|||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) |
|||
{ |
|||
argumentPrefix = "-c"; |
|||
fileName = "/bin/bash"; |
|||
} |
|||
else |
|||
{ |
|||
argumentPrefix = "/C"; |
|||
fileName = "cmd.exe"; |
|||
} |
|||
|
|||
var procStartInfo = new ProcessStartInfo(fileName, |
|||
$"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\" --nolayers\"" |
|||
); |
|||
|
|||
try |
|||
{ |
|||
Process.Start(procStartInfo); |
|||
} |
|||
catch (Exception) |
|||
{ |
|||
throw new Exception("Couldn't run ABP CLI..."); |
|||
} |
|||
} |
|||
|
|||
private string GetEntityFrameworkCoreProjectFolderPath() |
|||
{ |
|||
var slnDirectoryPath = GetSolutionDirectoryPath(); |
|||
|
|||
if (slnDirectoryPath == null) |
|||
{ |
|||
throw new Exception("Solution folder not found!"); |
|||
} |
|||
|
|||
return Path.Combine(slnDirectoryPath, "PackageName.CompanyName.ProjectName.HttpApi.Host"); |
|||
} |
|||
|
|||
private string? GetSolutionDirectoryPath() |
|||
{ |
|||
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); |
|||
|
|||
while (Directory.GetParent(currentDirectory.FullName) != null) |
|||
{ |
|||
currentDirectory = Directory.GetParent(currentDirectory.FullName); |
|||
|
|||
if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) |
|||
{ |
|||
return currentDirectory.FullName; |
|||
} |
|||
|
|||
// parent host
|
|||
currentDirectory = Directory.GetParent(currentDirectory.FullName); |
|||
if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) |
|||
{ |
|||
return currentDirectory.FullName; |
|||
} |
|||
} |
|||
|
|||
return null; |
|||
} |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
namespace PackageName.CompanyName.ProjectName.EntityFrameworkCore; |
|||
|
|||
public static class ProjectNameEfCoreQueryableExtensions |
|||
{ |
|||
// 在此聚合仓储服务的扩展方法
|
|||
} |
|||
@ -0,0 +1,65 @@ |
|||
using LINGYUN.Abp.Data.DbMigrator; |
|||
using LINGYUN.Abp.Saas.EntityFrameworkCore; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.EntityFrameworkCore; |
|||
using Volo.Abp.Modularity; |
|||
#if MySQL
|
|||
using Volo.Abp.EntityFrameworkCore.MySQL; |
|||
#elif SqlServer
|
|||
using Volo.Abp.EntityFrameworkCore.SqlServer; |
|||
#elif Sqlite
|
|||
using Volo.Abp.EntityFrameworkCore.Sqlite; |
|||
#elif Oracle
|
|||
using Volo.Abp.EntityFrameworkCore.Oracle; |
|||
#elif OracleDevart
|
|||
using Volo.Abp.EntityFrameworkCore.Oracle.Devart; |
|||
#elif PostgreSql
|
|||
using Volo.Abp.EntityFrameworkCore.PostgreSql; |
|||
#endif
|
|||
|
|||
namespace PackageName.CompanyName.ProjectName.EntityFrameworkCore; |
|||
|
|||
[DependsOn( |
|||
typeof(ProjectNameDomainModule), |
|||
typeof(AbpDataDbMigratorModule), |
|||
typeof(AbpEntityFrameworkCoreModule), |
|||
#if MySQL
|
|||
typeof(AbpEntityFrameworkCoreMySQLModule), |
|||
#elif SqlServer
|
|||
typeof(AbpEntityFrameworkCoreSqlServerModule), |
|||
#elif Sqlite
|
|||
typeof(AbpEntityFrameworkCoreSqliteModule), |
|||
#elif Oracle
|
|||
typeof(AbpEntityFrameworkCoreOracleModule), |
|||
#elif OracleDevart
|
|||
typeof(AbpEntityFrameworkCoreOracleDevartModule), |
|||
#elif PostgreSql
|
|||
typeof(AbpEntityFrameworkCorePostgreSqlModule), |
|||
#endif
|
|||
typeof(AbpSaasEntityFrameworkCoreModule))] |
|||
public class ProjectNameEntityFrameworkCoreModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
// 配置Ef
|
|||
Configure<AbpDbContextOptions>(options => |
|||
{ |
|||
#if MySQL
|
|||
options.UseMySQL<ProjectNameDbContext>(); |
|||
#elif SqlServer
|
|||
options.UseSqlServer<ProjectNameDbContext>(); |
|||
#elif Sqlite
|
|||
options.UseSqlite<ProjectNameDbContext>(); |
|||
#elif Oracle || OracleDevart
|
|||
options.UseOracle<ProjectNameDbContext>(); |
|||
#elif PostgreSql
|
|||
options.UseNpgsql<ProjectNameDbContext>(); |
|||
#endif
|
|||
}); |
|||
|
|||
context.Services.AddAbpDbContext<ProjectNameDbContext>(options => |
|||
{ |
|||
options.AddDefaultRepositories<IProjectNameDbContext>(); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using JetBrains.Annotations; |
|||
using Volo.Abp.EntityFrameworkCore.Modeling; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.EntityFrameworkCore; |
|||
|
|||
public class ProjectNameModelBuilderConfigurationOptions : AbpModelBuilderConfigurationOptions |
|||
{ |
|||
public ProjectNameModelBuilderConfigurationOptions( |
|||
[NotNull] string tablePrefix = "", |
|||
[CanBeNull] string schema = null) |
|||
: base( |
|||
tablePrefix, |
|||
schema) |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -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,19 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="../../common.props" /> |
|||
<Import Project="../../configureawait.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Http.Client" Version="$(VoloAbpPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\PackageName.CompanyName.ProjectName.Application.Contracts\PackageName.CompanyName.ProjectName.Application.Contracts.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,18 @@ |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.Http.Client; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpHttpClientModule), |
|||
typeof(ProjectNameApplicationContractsModule))] |
|||
public class ProjectNameHttpApiClientModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
context.Services.AddHttpClientProxies( |
|||
typeof(ProjectNameApplicationContractsModule).Assembly, |
|||
ProjectNameRemoteServiceConsts.RemoteServiceName); |
|||
} |
|||
} |
|||
@ -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,20 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="../../common.props" /> |
|||
<Import Project="../../configureawait.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net7.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.Dynamic.Queryable.HttpApi" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\PackageName.CompanyName.ProjectName.Application.Contracts\PackageName.CompanyName.ProjectName.Application.Contracts.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,12 @@ |
|||
using PackageName.CompanyName.ProjectName.Localization; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
|
|||
public abstract class ProjectNameControllerBase : AbpControllerBase |
|||
{ |
|||
protected ProjectNameControllerBase() |
|||
{ |
|||
LocalizationResource = typeof(ProjectNameResource); |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using LINGYUN.Abp.Dynamic.Queryable; |
|||
using PackageName.CompanyName.ProjectName.Localization; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
/// <summary>
|
|||
/// 提供动态查询控制器实现
|
|||
/// </summary>
|
|||
/// <typeparam name="TEntityDto">实体dto类型</typeparam>
|
|||
public abstract class ProjectNameDynamicQueryableControllerBase<TEntityDto> : DynamicQueryableControllerBase<TEntityDto> |
|||
{ |
|||
protected ProjectNameDynamicQueryableControllerBase( |
|||
IDynamicQueryableAppService<TEntityDto> service) |
|||
: base(service) |
|||
{ |
|||
LocalizationResource = typeof(ProjectNameResource); |
|||
} |
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
using PackageName.CompanyName.ProjectName.Localization; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc.Localization; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.Validation.Localization; |
|||
using LINGYUN.Abp.Dynamic.Queryable; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpAspNetCoreMvcModule), |
|||
typeof(ProjectNameApplicationContractsModule), |
|||
typeof(AbpDynamicQueryableHttpApiModule))] |
|||
public class ProjectNameHttpApiModule : AbpModule |
|||
{ |
|||
public override void PreConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
PreConfigure<IMvcBuilder>(mvcBuilder => |
|||
{ |
|||
mvcBuilder.AddApplicationPartIfNotExists(typeof(ProjectNameHttpApiModule).Assembly); |
|||
}); |
|||
|
|||
PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options => |
|||
{ |
|||
options.AddAssemblyResource( |
|||
typeof(ProjectNameResource), |
|||
typeof(ProjectNameApplicationContractsModule).Assembly); |
|||
}); |
|||
} |
|||
|
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpLocalizationOptions>(options => |
|||
{ |
|||
options.Resources |
|||
.Get<ProjectNameResource>() |
|||
.AddBaseTypes(typeof(AbpValidationResource)); |
|||
}); |
|||
} |
|||
} |
|||
@ -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,21 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="../../common.props" /> |
|||
<Import Project="../../configureawait.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net7.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.SettingManagement.Domain" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="LINGYUN.Abp.SettingManagement.Application.Contracts" Version="$(LINGYUNAbpPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\PackageName.CompanyName.ProjectName.Application.Contracts\PackageName.CompanyName.ProjectName.Application.Contracts.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,7 @@ |
|||
using LINGYUN.Abp.SettingManagement; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.SettingManagement; |
|||
|
|||
public interface IProjectNameSettingAppService : ISettingAppService, IUserSettingAppService |
|||
{ |
|||
} |
|||
@ -0,0 +1,106 @@ |
|||
using LINGYUN.Abp.SettingManagement; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using PackageName.CompanyName.ProjectName.Authorization; |
|||
using PackageName.CompanyName.ProjectName.Localization; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Features; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.SettingManagement; |
|||
using Volo.Abp.Settings; |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.SettingManagement; |
|||
|
|||
public class ProjectNameSettingAppService : ApplicationService, IProjectNameSettingAppService |
|||
{ |
|||
protected ISettingManager SettingManager { get; } |
|||
protected ISettingDefinitionManager SettingDefinitionManager { get; } |
|||
|
|||
public ProjectNameSettingAppService( |
|||
ISettingManager settingManager, |
|||
ISettingDefinitionManager settingDefinitionManager) |
|||
{ |
|||
SettingManager = settingManager; |
|||
SettingDefinitionManager = settingDefinitionManager; |
|||
LocalizationResource = typeof(ProjectNameResource); |
|||
} |
|||
|
|||
public virtual async Task<SettingGroupResult> GetAllForCurrentTenantAsync() |
|||
{ |
|||
return await GetAllForProviderAsync(TenantSettingValueProvider.ProviderName, CurrentTenant.GetId().ToString()); |
|||
} |
|||
|
|||
[Authorize] |
|||
public virtual async Task<SettingGroupResult> GetAllForCurrentUserAsync() |
|||
{ |
|||
return await GetAllForProviderAsync(UserSettingValueProvider.ProviderName, CurrentUser.GetId().ToString()); |
|||
} |
|||
|
|||
public virtual async Task<SettingGroupResult> GetAllForGlobalAsync() |
|||
{ |
|||
return await GetAllForProviderAsync(GlobalSettingValueProvider.ProviderName, null); |
|||
} |
|||
|
|||
[Authorize(ProjectNamePermissions.ManageSettings)] |
|||
public virtual async Task SetCurrentTenantAsync(UpdateSettingsDto input) |
|||
{ |
|||
// 增加特性检查
|
|||
await CheckFeatureAsync(); |
|||
|
|||
if (CurrentTenant.IsAvailable) |
|||
{ |
|||
foreach (var setting in input.Settings) |
|||
{ |
|||
await SettingManager.SetForTenantAsync(CurrentTenant.GetId(), setting.Name, setting.Value); |
|||
} |
|||
|
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
} |
|||
} |
|||
|
|||
[Authorize] |
|||
public virtual async Task SetCurrentUserAsync(UpdateSettingsDto input) |
|||
{ |
|||
// 增加特性检查
|
|||
await CheckFeatureAsync(); |
|||
|
|||
foreach (var setting in input.Settings) |
|||
{ |
|||
await SettingManager.SetForCurrentUserAsync(setting.Name, setting.Value); |
|||
} |
|||
|
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
} |
|||
|
|||
[Authorize(ProjectNamePermissions.ManageSettings)] |
|||
public virtual async Task SetGlobalAsync(UpdateSettingsDto input) |
|||
{ |
|||
// 增加特性检查
|
|||
await CheckFeatureAsync(); |
|||
|
|||
foreach (var setting in input.Settings) |
|||
{ |
|||
await SettingManager.SetGlobalAsync(setting.Name, setting.Value); |
|||
} |
|||
|
|||
await CurrentUnitOfWork.SaveChangesAsync(); |
|||
} |
|||
|
|||
|
|||
protected virtual async Task CheckFeatureAsync() |
|||
{ |
|||
await FeatureChecker.CheckEnabledAsync(SettingManagementFeatures.Enable); |
|||
} |
|||
|
|||
protected virtual async Task<SettingGroupResult> GetAllForProviderAsync(string providerName, string providerKey) |
|||
{ |
|||
var settingGroups = new SettingGroupResult(); |
|||
|
|||
//TODO: 当前项目所有配置项在此定义返回
|
|||
|
|||
await Task.CompletedTask; |
|||
|
|||
return settingGroups; |
|||
} |
|||
} |
|||
@ -0,0 +1,68 @@ |
|||
using LINGYUN.Abp.SettingManagement; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using PackageName.CompanyName.ProjectName.Authorization; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.SettingManagement; |
|||
|
|||
[RemoteService(Name = ProjectNameRemoteServiceConsts.RemoteServiceName)] |
|||
[ApiVersion("2.0")] |
|||
[Area(ProjectNameRemoteServiceConsts.ModuleName)] |
|||
[Route("api/ProjectName/settings")] |
|||
public class ProjectNameSettingController : AbpController, IProjectNameSettingAppService |
|||
{ |
|||
private readonly IProjectNameSettingAppService _settingAppService; |
|||
public ProjectNameSettingController(IProjectNameSettingAppService settingAppService) |
|||
{ |
|||
_settingAppService = settingAppService; |
|||
} |
|||
|
|||
[Authorize(ProjectNamePermissions.ManageSettings)] |
|||
[HttpPut] |
|||
[Route("by-current-tenant")] |
|||
public virtual async Task SetCurrentTenantAsync(UpdateSettingsDto input) |
|||
{ |
|||
await _settingAppService.SetCurrentTenantAsync(input); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("by-current-tenant")] |
|||
public virtual async Task<SettingGroupResult> GetAllForCurrentTenantAsync() |
|||
{ |
|||
return await _settingAppService.GetAllForCurrentTenantAsync(); |
|||
} |
|||
|
|||
[Authorize] |
|||
[HttpPut] |
|||
[Route("by-current-user")] |
|||
public virtual async Task SetCurrentUserAsync(UpdateSettingsDto input) |
|||
{ |
|||
await _settingAppService.SetCurrentTenantAsync(input); |
|||
} |
|||
|
|||
[Authorize] |
|||
[HttpGet] |
|||
[Route("by-current-user")] |
|||
public virtual async Task<SettingGroupResult> GetAllForCurrentUserAsync() |
|||
{ |
|||
return await _settingAppService.GetAllForCurrentTenantAsync(); |
|||
} |
|||
|
|||
[Authorize(ProjectNamePermissions.ManageSettings)] |
|||
[HttpPut] |
|||
[Route("by-global")] |
|||
public virtual async Task SetGlobalAsync(UpdateSettingsDto input) |
|||
{ |
|||
await _settingAppService.SetGlobalAsync(input); |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("by-global")] |
|||
public virtual async Task<SettingGroupResult> GetAllForGlobalAsync() |
|||
{ |
|||
return await _settingAppService.GetAllForGlobalAsync(); |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using LINGYUN.Abp.SettingManagement; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.SettingManagement; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName.SettingManagement; |
|||
|
|||
[DependsOn( |
|||
typeof(AbpSettingManagementApplicationContractsModule), |
|||
typeof(AbpAspNetCoreMvcModule), |
|||
typeof(AbpSettingManagementDomainModule))] |
|||
public class ProjectNameSettingManagementModule : AbpModule |
|||
{ |
|||
public override void PreConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
PreConfigure<IMvcBuilder>(mvcBuilder => |
|||
{ |
|||
mvcBuilder.AddApplicationPartIfNotExists(typeof(ProjectNameSettingManagementModule).Assembly); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>net7.0</TargetFramework> |
|||
<RootNamespace /> |
|||
<IsPackable>false</IsPackable> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\PackageName.CompanyName.ProjectName.Application\PackageName.CompanyName.ProjectName.Application.csproj" /> |
|||
<ProjectReference Include="..\PackageName.CompanyName.ProjectName.Domain.Tests\PackageName.CompanyName.ProjectName.Domain.Tests.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,6 @@ |
|||
namespace PackageName.CompanyName.ProjectName |
|||
{ |
|||
public abstract class ProjectNameApplicationTestBase : ProjectNameTestBase<ProjectNameApplicationTestModule> |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace PackageName.CompanyName.ProjectName |
|||
{ |
|||
[DependsOn( |
|||
typeof(ProjectNameDomainTestModule), |
|||
typeof(ProjectNameApplicationModule) |
|||
)] |
|||
public class ProjectNameApplicationTestModule : AbpModule |
|||
{ |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue