Browse Source

feat: 调整模板

abp/9.3.0.4 9.3.0.3
zzzwangjun@gmail.com 7 months ago
parent
commit
b6ac91981c
  1. 10
      aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/GlobalUsings.cs
  2. 1
      aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Lion.AbpPro.HttpApi.Host.csproj
  3. 3
      templates/pro-nuget/service/Directory.Build.Lion.targets
  4. 86
      templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/Microsoft/Extensions/DependencyInjection/ServiceCollectionExtensions.cs
  5. 29
      templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj
  6. 1
      templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs
  7. 68
      templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/appsettings.Production.json
  8. 69
      templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/appsettings.json
  9. 1
      templates/pro-nuget/service/src/MyCompanyName.MyProjectName.Domain.Shared/MyCompanyName.MyProjectName.Domain.Shared.csproj

10
aspnet-core/frameworks/src/Lion.AbpPro.AspNetCore/GlobalUsings.cs

@ -5,31 +5,23 @@ global using Ocelot.DependencyInjection;
global using Ocelot.Provider.Consul;
global using Ocelot.Provider.Polly;
global using Volo.Abp.Modularity;
global using System;
global using System.Collections.Concurrent;
global using System.Collections.Generic;
global using System.Diagnostics.CodeAnalysis;
global using System.Linq;
global using System.Net;
global using System.Reflection;
global using System.Text;
global using System.Text.Json;
global using System.Threading.Tasks;
global using Lion.AbpPro;
global using Lion.AbpPro.Core;
global using Lion.AbpPro.Localization;
global using Microsoft.AspNetCore.Builder;
global using Microsoft.AspNetCore.Cors;
global using Microsoft.AspNetCore.Hosting;
global using Microsoft.AspNetCore.Http;
global using Microsoft.AspNetCore.HttpsPolicy;
global using Microsoft.AspNetCore.Mvc;
global using Microsoft.AspNetCore.Mvc.Abstractions;
global using Microsoft.AspNetCore.Mvc.ApiExplorer;
global using Microsoft.EntityFrameworkCore;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.Hosting;
global using Microsoft.Extensions.Localization;
global using Microsoft.Extensions.Logging;
@ -42,7 +34,6 @@ global using Serilog.Exceptions;
global using Serilog.Sinks.Elasticsearch;
global using Swashbuckle.AspNetCore.Swagger;
global using Swashbuckle.AspNetCore.SwaggerGen;
global using Volo.Abp;
global using Volo.Abp.AspNetCore.ExceptionHandling;
global using Volo.Abp.AspNetCore.Mvc;
global using Volo.Abp.AspNetCore.Mvc.ExceptionHandling;
@ -52,5 +43,4 @@ global using Volo.Abp.Domain.Entities;
global using Volo.Abp.ExceptionHandling;
global using Volo.Abp.Http;
global using Volo.Abp.Json;
global using Volo.Abp.Modularity;
global using Volo.Abp.Validation;

1
aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/Lion.AbpPro.HttpApi.Host.csproj

@ -20,7 +20,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis"/>
<PackageReference Include="DotNetCore.CAP.MySql"/>
<PackageReference Include="DotNetCore.CAP.RabbitMQ"/>

3
templates/pro-nuget/service/Directory.Build.Lion.targets

@ -2,8 +2,7 @@
<!-- Lion.AbpPro包-->
<ItemGroup>
<PackageReference Update="Lion.AbpPro.Core" Version="MyVersion"/>
<PackageReference Update="Lion.AbpPro.Shared.Hosting.Microservices" Version="MyVersion"/>
<PackageReference Update="Lion.AbpPro.Shared.Hosting.Gateways" Version="MyVersion"/>
<PackageReference Update="Lion.AbpPro.AspNetCore" Version="MyVersion"/>
<PackageReference Update="Lion.AbpPro.BasicManagement.Application" Version="MyVersion"/>
<PackageReference Update="Lion.AbpPro.BasicManagement.Application.Contracts" Version="MyVersion"/>

86
templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/Microsoft/Extensions/DependencyInjection/ServiceCollectionExtensions.cs

@ -0,0 +1,86 @@
using Hangfire.Redis.StackExchange;
using Medallion.Threading;
using Medallion.Threading.Redis;
#pragma warning disable CS0618 // Type or member is obsolete
namespace Microsoft.Extensions.DependencyInjection;
public static class ServiceCollectionExtensions
{
/// <summary>
/// 注册Redis缓存
/// </summary>
public static IServiceCollection AddAbpProRedis(this IServiceCollection service)
{
service.Configure<AbpDistributedCacheOptions>(options => { options.KeyPrefix = "AbpPro:"; });
var configuration = service.GetConfiguration();
var redis = ConnectionMultiplexer.Connect(configuration.GetValue<string>("Redis:Configuration"));
service
.AddDataProtection()
.PersistKeysToStackExchangeRedis(redis, "AbpPro-Protection-Keys");
return service;
}
/// <summary>
/// 注册redis分布式锁
/// </summary>
public static IServiceCollection AddAbpProRedisDistributedLocking(this IServiceCollection service)
{
var configuration = service.GetConfiguration();
var connectionString = configuration.GetValue<string>("Redis:Configuration");
service.AddSingleton<IDistributedLockProvider>(sp =>
{
var connection = ConnectionMultiplexer.Connect(connectionString);
return new RedisDistributedSynchronizationProvider(connection.GetDatabase());
});
return service;
}
/// <summary>
/// 注册Identity
/// </summary>
public static IServiceCollection AddAbpProIdentity(this IServiceCollection service)
{
service.Configure<IdentityOptions>(options => { options.Lockout = new LockoutOptions() { AllowedForNewUsers = false }; });
return service;
}
/// <summary>
/// 注册SignalR
/// </summary>
public static IServiceCollection AddAbpProSignalR(this IServiceCollection service)
{
service
.AddSignalR()
.AddStackExchangeRedis(service.GetConfiguration().GetValue<string>("Redis:Configuration"),
options => { options.Configuration.ChannelPrefix = "Lion.AbpPro"; });
return service;
}
/// <summary>
/// 注册hangfire
/// </summary>
public static IServiceCollection AddAbpProHangfire(this IServiceCollection service)
{
var redisStorageOptions = new RedisStorageOptions()
{
Db = service.GetConfiguration().GetValue<int>("Hangfire:Redis:DB")
};
service.Configure<AbpBackgroundJobOptions>(options => { options.IsJobExecutionEnabled = true; });
service.AddHangfire(config =>
{
config.UseRedisStorage(service.GetConfiguration().GetValue<string>("Hangfire:Redis:Host"), redisStorageOptions)
.WithJobExpirationTimeout(TimeSpan.FromDays(7));
var delaysInSeconds = new[] { 10, 60, 60 * 3 }; // 重试时间间隔
const int attempts = 3; // 重试次数
config.UseFilter(new AutomaticRetryAttribute() { Attempts = 3, DelaysInSeconds = delaysInSeconds });
//config.UseFilter(new AutoDeleteAfterSuccessAttribute(TimeSpan.FromDays(7)));
//config.UseFilter(new JobRetryLastFilter(attempts));
});
return service;
}
}

29
templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj

@ -9,35 +9,28 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer"/>
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis"/>
<PackageReference Include="Volo.Abp.Account.Web"/>
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy"/>
<PackageReference Include="Volo.Abp.Autofac"/>
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis"/>
<PackageReference Include="Volo.Abp.AspNetCore.Serilog"/>
<PackageReference Include="Volo.Abp.Swashbuckle"/>
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer"/>
<PackageReference Include="Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic"/>
<PackageReference Include="Serilog"/>
<PackageReference Include="Serilog.AspNetCore"/>
<PackageReference Include="Serilog.Exceptions"/>
<PackageReference Include="Serilog.Extensions.Logging"/>
<PackageReference Include="Serilog.Settings.Configuration"/>
<PackageReference Include="Serilog.Sinks.Console"/>
<PackageReference Include="Serilog.Sinks.Elasticsearch"/>
<PackageReference Include="Serilog.Sinks.File"/>
<PackageReference Include="Serilog.Sinks.Async"/>
<PackageReference Include="Hangfire.Redis.StackExchange"/>
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks"/>
<PackageReference Include="MiniProfiler.AspNetCore.Mvc"/>
<PackageReference Include="Volo.Abp.DistributedLocking"/>
<PackageReference Include="Volo.Abp.BlobStoring.FileSystem"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis"/>
<PackageReference Include="DotNetCore.CAP.MySql"/>
<PackageReference Include="DotNetCore.CAP.RabbitMQ"/>
<PackageReference Include="DotNetCore.CAP.Dashboard"/>
<PackageReference Include="MiniProfiler.AspNetCore.Mvc"/>
<PackageReference Include="MiniProfiler.EntityFrameworkCore"/>
<PackageReference Include="MiniProfiler.Shared"/>
<PackageReference Include="DistributedLock.Redis"/>
<PackageReference Include="Hangfire.Redis.StackExchange"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\MyCompanyName.MyProjectName.Application\MyCompanyName.MyProjectName.Application.csproj"/>

1
templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs

@ -39,7 +39,6 @@ namespace MyCompanyName.MyProjectName
.AddAbpProCors()
.AddAbpProAntiForgery()
.AddAbpProIdentity()
.AddAbpProBlobStorage()
.AddAbpProSignalR()
.AddAbpProHealthChecks()
.AddAbpProTenantResolvers()

68
templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/appsettings.Production.json

@ -5,7 +5,7 @@
"Serilog.Sinks.File"
],
"MinimumLevel": {
"Default": "Information",
"Default": "Debug",
"Override": {
"Microsoft": "Information",
"Volo.Abp": "Information",
@ -26,31 +26,77 @@
"path": "logs/logs-.txt",
"rollingInterval": "Day"
}
},
{
"Name": "Elastic",
"Args": {
"Enabled": false,
"Url": "http://es.cn",
"IndexFormat": "Lion.AbpPro.development.{0:yyyy.MM.dd}",
"UserName": "elastic",
"Password": "aVVhjQ95RP7nbwNy",
"ApplicationName": "Lion.AbpPro.HttpApi.Host"
}
}
]
},
"App": {
"SelfUrl": "http://localhost:44315",
"CorsOrigins": "https://*.MyProjectName.com,http://localhost:4200,http://localhost:3100,http://localhost:80,http://localhost"
},
"ConnectionStrings": {
"Default": "Data Source=mysql;Port=3306;Database=MyCompanyNameMyProjectNameDB;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"
"Default": "Data Source=localhost;Port=3306;Database=LionAbpProDemo9;uid=root;pwd=f616b8803ac7a9a0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"
},
"Hangfire": {
"Redis": {
"Host": "localhost:6379,password=1q2w3E*",
"DB": "2"
}
},
"Redis": {
"Configuration": "localhost,password=1q2w3E*,defaultdatabase=1"
"Configuration": "localhost:6379,password=75He82bB5jFA84XZ1,defaultdatabase=2"
},
"Jwt": {
"Audience": "MyCompanyName.MyProjectName",
"Audience": "Lion.AbpPro",
"SecurityKey": "dzehzRz9a8asdfasfdadfasdfasdfafsdadfasbasdf=",
"Issuer": "MyCompanyName.MyProjectName",
"Issuer": "Lion.AbpPro",
"ExpirationTime": 2
},
"Cap": {
"RabbitMq": {
"HostName": "localhost",
"UserName": "admin",
"Password": "1q2w3E*",
"Port": 5672
}
},
"ElasticSearch": {
"Enabled": "false",
"Url": "http://es.cn",
"IndexFormat": "MyCompanyName.MyProjectName.development.{0:yyyy.MM.dd}",
"Host": "http://es.cn",
"UserName": "elastic",
"Password": "aVVhjQ95RP7nbwNy",
"SearchIndexFormat": "MyCompanyName.MyProjectName.development*"
"Password": "aVVhjQ95RP7nbwNy"
},
"MiniProfiler": {
"Enabled": true,
"RouteBasePath": "/profiler"
},
"Swagger": {
"Enabled": true
},
"Audit": {
"Enabled": true,
"ApplicationName": "Lion.AbpPro"
},
"Cors": {
"Enabled": true,
"CorsOrigins": "http://localhost:4200,http://localhost:4201"
},
"Gateway": {
"Enabled": false
},
"MultiTenancy": {
"Enabled": true
},
"Preheat": {
"Enabled": true,
"RequestUrl": "http://localhost:44315/api/abp/application-configuration?IncludeLocalizationResources=false"
}
}

69
templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/appsettings.json

@ -26,36 +26,77 @@
"path": "logs/logs-.txt",
"rollingInterval": "Day"
}
},
{
"Name": "Elastic",
"Args": {
"Enabled": false,
"Url": "http://es.cn",
"IndexFormat": "Lion.AbpPro.development.{0:yyyy.MM.dd}",
"UserName": "elastic",
"Password": "aVVhjQ95RP7nbwNy",
"ApplicationName": "Lion.AbpPro.HttpApi.Host"
}
}
]
},
"App": {
"SelfUrl": "http://localhost:44315",
"CorsOrigins": "https://*.MyProjectName.com,http://localhost:4200,http://localhost:3100"
},
"ConnectionStrings": {
"Default": "Data Source=localhost;Port=3306;Database=MyCompanyNameMyProjectNameDB;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"
"Default": "Data Source=localhost;Port=3306;Database=LionAbpProDemo9;uid=root;pwd=f616b8803ac7a9a0;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"
},
"Hangfire": {
"Redis": {
"Host": "localhost:6379,password=1q2w3E*",
"DB": "2"
}
},
"Redis": {
"Configuration": "localhost,password=1q2w3E*,defaultdatabase=1"
"Configuration": "localhost:6379,password=75He82bB5jFA84XZ1,defaultdatabase=2"
},
"Jwt": {
"Audience": "MyCompanyName.MyProjectName",
"Audience": "Lion.AbpPro",
"SecurityKey": "dzehzRz9a8asdfasfdadfasdfasdfafsdadfasbasdf=",
"Issuer": "MyCompanyName.MyProjectName",
"Issuer": "Lion.AbpPro",
"ExpirationTime": 2
},
"Cap": {
"RabbitMq": {
"HostName": "localhost",
"UserName": "admin",
"Password": "1q2w3E*",
"Port": 5672
}
},
"ElasticSearch": {
"Enabled": "false",
"Url": "http://es.cn",
"IndexFormat": "MyCompanyName.MyProjectName.development.{0:yyyy.MM.dd}",
"Host": "http://es.cn",
"UserName": "elastic",
"Password": "aVVhjQ95RP7nbwNy",
"SearchIndexFormat": "MyCompanyName.MyProjectName.development*"
"Password": "aVVhjQ95RP7nbwNy"
},
"MiniProfiler": {
"Enabled": true,
"RouteBasePath": "/profiler"
},
"Swagger": {
"Enabled": true
},
"Audit": {
"Enabled": true,
"ApplicationName": "Lion.AbpPro"
},
"Cors": {
"Enabled": true,
"CorsOrigins": "http://localhost:4200,http://localhost:4201"
},
"Gateway": {
"Enabled": false
},
"MultiTenancy": {
"Enabled": true
},
"Consul": {
"Enabled": false,
"Host": "http://localhost:8500",
"Service": "Project-Service"
"Preheat": {
"Enabled": true,
"RequestUrl": "http://localhost:44315/api/abp/application-configuration?IncludeLocalizationResources=false"
}
}

1
templates/pro-nuget/service/src/MyCompanyName.MyProjectName.Domain.Shared/MyCompanyName.MyProjectName.Domain.Shared.csproj

@ -12,6 +12,7 @@
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\aspnet-core\frameworks\src\Lion.AbpPro.Core\Lion.AbpPro.Core.csproj"/>
<ProjectReference Include="..\..\..\..\..\aspnet-core\modules\BasicManagement\src\Lion.AbpPro.BasicManagement.Domain.Shared\Lion.AbpPro.BasicManagement.Domain.Shared.csproj"/>
<ProjectReference Include="..\..\..\..\..\aspnet-core\modules\NotificationManagement\src\Lion.AbpPro.NotificationManagement.Domain.Shared\Lion.AbpPro.NotificationManagement.Domain.Shared.csproj"/>

Loading…
Cancel
Save