Browse Source

feat: 调整模板

abp/9.3.0.4 9.3.0.2
zzzwangjun@gmail.com 8 months ago
parent
commit
1945102b64
  1. 1
      aspnet-core/services/host/Lion.AbpPro.HttpApi.Host/AbpProHttpApiHostModule.cs
  2. 21
      templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/Extensions/Hangfire/AutoDeleteAfterSuccessAttributer.cs
  3. 78
      templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/Extensions/Hangfire/CronType.cs
  4. 11
      templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/Extensions/Hangfire/CustomHangfireAuthorizeFilter.cs
  5. 24
      templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/Extensions/Hangfire/JobRetryLastFilter.cs
  6. 15
      templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/Extensions/Hangfire/RecurringJobsExtensions.cs
  7. 2
      templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/GlobalUsings.cs
  8. 2
      templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/MyCompanyName.MyProjectName.HttpApi.Host.csproj
  9. 27
      templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs
  10. 4
      templates/pro-nuget/service/host/MyCompanyName.MyProjectName.WebGateway/AbpProWebGatewayModule.cs
  11. 2
      templates/pro-nuget/service/host/MyCompanyName.MyProjectName.WebGateway/MyCompanyName.MyProjectName.WebGateway.csproj
  12. 1
      templates/pro-nuget/service/src/MyCompanyName.MyProjectName.EntityFrameworkCore/GlobalUsings.cs

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

@ -24,7 +24,6 @@ public partial class AbpProHttpApiHostModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services
.AddAbpProAuditLog()
.AddAbpProAuthentication()
.AddAbpProMultiTenancy()

21
templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/Extensions/Hangfire/AutoDeleteAfterSuccessAttributer.cs

@ -1,21 +0,0 @@
namespace MyCompanyName.MyProjectName.Extensions.Hangfire;
public class AutoDeleteAfterSuccessAttributer : JobFilterAttribute, IApplyStateFilter
{
private readonly TimeSpan _deleteAfter;
public AutoDeleteAfterSuccessAttributer(TimeSpan timeSpan)
{
_deleteAfter = timeSpan;
}
public void OnStateApplied(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
context.JobExpirationTimeout = _deleteAfter;
}
public void OnStateUnapplied(ApplyStateContext context, IWriteOnlyTransaction transaction)
{
}
}

78
templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/Extensions/Hangfire/CronType.cs

@ -1,78 +0,0 @@
namespace MyCompanyName.MyProjectName.Extensions.Hangfire
{
/// <summary>
/// Cron类型
/// </summary>
public static class CronType
{
/// <summary>
/// 周期性为分钟的任务
/// </summary>
/// <param name="interval">执行周期的间隔,默认为每分钟一次</param>
/// <returns></returns>
public static string Minute(int interval = 1)
{
return "1 0/" + interval.ToString() + " * * * ? ";
}
/// <summary>
/// 周期性为小时的任务
/// </summary>
/// <param name="minute">第几分钟开始,默认为第一分钟</param>
/// <param name="interval">执行周期的间隔,默认为每小时一次</param>
/// <returns></returns>
public static string Hour(int minute = 1, int interval = 1)
{
return "1 " + minute + " 0/" + interval.ToString() + " * * ? ";
}
/// <summary>
/// 周期性为天的任务
/// </summary>
/// <param name="hour">第几小时开始,默认从1点开始</param>
/// <param name="minute">第几分钟开始,默认从第1分钟开始</param>
/// <param name="interval">执行周期的间隔,默认为每天一次</param>
/// <returns></returns>
public static string Day(int hour = 1, int minute = 1, int interval = 1)
{
return "1 " + minute.ToString() + " " + hour.ToString() + " 1/" + interval.ToString() + " * ? ";
}
/// <summary>
/// 周期性为周的任务
/// </summary>
/// <param name="dayOfWeek">星期几开始,默认从星期一点开始</param>
/// <param name="hour">第几小时开始,默认从1点开始</param>
/// <param name="minute">第几分钟开始,默认从第1分钟开始</param>
/// <returns></returns>
public static string Week(DayOfWeek dayOfWeek = DayOfWeek.Monday, int hour = 1, int minute = 1)
{
return Cron.Weekly(dayOfWeek, hour, minute);
}
/// <summary>
/// 周期性为月的任务
/// </summary>
/// <param name="day">几号开始,默认从一号开始</param>
/// <param name="hour">第几小时开始,默认从1点开始</param>
/// <param name="minute">第几分钟开始,默认从第1分钟开始</param>
/// <returns></returns>
public static string Month(int day = 1, int hour = 1, int minute = 1)
{
return Cron.Monthly(day, hour, minute);
}
/// <summary>
/// 周期性为年的任务
/// </summary>
/// <param name="month">几月开始,默认从一月开始</param>
/// <param name="day">几号开始,默认从一号开始</param>
/// <param name="hour">第几小时开始,默认从1点开始</param>
/// <param name="minute">第几分钟开始,默认从第1分钟开始</param>
/// <returns></returns>
public static string Year(int month = 1, int day = 1, int hour = 1, int minute = 1)
{
return Cron.Yearly(month, day, hour, minute);
}
}
}

11
templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/Extensions/Hangfire/CustomHangfireAuthorizeFilter.cs

@ -1,11 +0,0 @@
namespace MyCompanyName.MyProjectName.Extensions.Hangfire
{
public class CustomHangfireAuthorizeFilter : IDashboardAuthorizationFilter
{
public bool Authorize(DashboardContext context)
{
var _currentUser = context.GetHttpContext().RequestServices.GetRequiredService<ICurrentUser>();
return _currentUser.IsAuthenticated;
}
}
}

24
templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/Extensions/Hangfire/JobRetryLastFilter.cs

@ -1,24 +0,0 @@
namespace MyCompanyName.MyProjectName.Extensions.Hangfire;
/// <summary>
/// 重试最后一次
/// </summary>
public class JobRetryLastFilter : JobFilterAttribute, IElectStateFilter
{
private int RetryCount { get; }
public JobRetryLastFilter(int retryCount)
{
RetryCount = retryCount;
}
public void OnStateElection(ElectStateContext context)
{
var retryAttempt = context.GetJobParameter<int>("RetryCount");
if (RetryCount == retryAttempt)
{
Log.Error("最后一次重试");
}
}
}

15
templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/Extensions/Hangfire/RecurringJobsExtensions.cs

@ -1,15 +0,0 @@
using MyCompanyName.MyProjectName.Jobs;
namespace MyCompanyName.MyProjectName.Extensions.Hangfire
{
public static class RecurringJobsExtensions
{
public static void CreateRecurringJob(this ApplicationInitializationContext context)
{
RecurringJob.AddOrUpdate<TestJob>("测试Job", e => e.ExecuteAsync(), CronType.Minute(1), new RecurringJobOptions()
{
TimeZone = TimeZoneInfo.Local
});
}
}
}

2
templates/pro-nuget/service/host/MyCompanyName.MyProjectName.HttpApi.Host/GlobalUsings.cs

@ -14,8 +14,6 @@ global using Hangfire.States;
global using Hangfire.Storage;
global using Lion.AbpPro;
global using MyCompanyName.MyProjectName.EntityFrameworkCore;
global using MyCompanyName.MyProjectName.Extensions;
global using MyCompanyName.MyProjectName.Extensions.Hangfire;
global using MyCompanyName.MyProjectName.MultiTenancy;
global using Microsoft.AspNetCore.Authentication.JwtBearer;
global using Microsoft.AspNetCore.Builder;

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

@ -46,7 +46,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\aspnet-core\shared\Lion.AbpPro.Shared.Hosting.Microservices\Lion.AbpPro.Shared.Hosting.Microservices.csproj"/>
<ProjectReference Include="..\..\..\..\..\aspnet-core\frameworks\src\Lion.AbpPro.AspNetCore\Lion.AbpPro.AspNetCore.csproj"/>
</ItemGroup>
<ItemGroup>

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

@ -1,8 +1,10 @@
using Lion.AbpPro.AspNetCore;
namespace MyCompanyName.MyProjectName
{
[DependsOn(
typeof(MyProjectNameHttpApiModule),
typeof(AbpProSharedHostingMicroserviceModule),
typeof(AbpProAspNetCoreModule),
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
@ -25,6 +27,25 @@ namespace MyCompanyName.MyProjectName
ConfigureAuditLog(context);
ConfigurationSignalR(context);
ConfigurationMultiTenancy();
context.Services
.AddAbpProAuditLog()
.AddAbpProAuthentication()
.AddAbpProMultiTenancy()
.AddAbpProRedis()
.AddAbpProRedisDistributedLocking()
.AddAbpProMiniProfiler()
.AddAbpProCors()
.AddAbpProAntiForgery()
.AddAbpProIdentity()
.AddAbpProBlobStorage()
.AddAbpProSignalR()
.AddAbpProHealthChecks()
.AddAbpProTenantResolvers()
.AddAbpProLocalization()
.AddAbpProExceptions()
.AddAbpProSwagger("AbpPro");
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
@ -71,10 +92,6 @@ namespace MyCompanyName.MyProjectName
});
if (configuration.GetValue("Consul:Enabled", false))
{
app.UseConsul();
}
}
private void ConfigurationSignalR(ServiceConfigurationContext context)

4
templates/pro-nuget/service/host/MyCompanyName.MyProjectName.WebGateway/AbpProWebGatewayModule.cs

@ -1,7 +1,9 @@
using Lion.AbpPro.AspNetCore;
namespace Lion.AbpPro.WebGateway
{
[DependsOn(
typeof(AbpProSharedHostingGatewayModule))]
typeof(AbpProAspNetCoreModule))]
public class AbpProWebGatewayModule : AbpModule
{
private const string DefaultCorsPolicyName = "Default";

2
templates/pro-nuget/service/host/MyCompanyName.MyProjectName.WebGateway/MyCompanyName.MyProjectName.WebGateway.csproj

@ -5,6 +5,6 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\aspnet-core\shared\Lion.AbpPro.Shared.Hosting.Gateways\Lion.AbpPro.Shared.Hosting.Gateways.csproj"/>
<ProjectReference Include="..\..\..\..\..\aspnet-core\frameworks\src\Lion.AbpPro.AspNetCore\Lion.AbpPro.AspNetCore.csproj"/>
</ItemGroup>
</Project>

1
templates/pro-nuget/service/src/MyCompanyName.MyProjectName.EntityFrameworkCore/GlobalUsings.cs

@ -23,7 +23,6 @@ global using Microsoft.EntityFrameworkCore.Design;
global using Microsoft.EntityFrameworkCore.Storage;
global using Microsoft.Extensions.Configuration;
global using Microsoft.Extensions.DependencyInjection;
global using MySqlConnector;
global using Volo.Abp;
global using Volo.Abp.AuditLogging;
global using Volo.Abp.BackgroundJobs;

Loading…
Cancel
Save