feat 框架升级,代码整合
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
using Dlhis.Basic.BusinessPlace.Response;
|
||||
using Dlhis.Basic.BusinessPlace.Services;
|
||||
using Dlhis.Basic.BusinessShift.Services;
|
||||
using Dlhis.Basic.Packs;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Dlhis.Basic.BusinessShift.Request;
|
||||
using Dlhis.Basic.BusinessShift.Response;
|
||||
using Dlhis.Basic.BusinessShift.Services;
|
||||
using Dlhis.Basic.Packs;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using Dlhis.Basic.Device.Request;
|
||||
using Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Basic.Device.Services;
|
||||
using Dlhis.Basic.Packs;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -3,6 +3,7 @@ using Dlhis.Basic.Device.Request;
|
||||
using Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Basic.Device.Services;
|
||||
using Dlhis.Basic.Packs;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Dlhis.Basic.Device.Request;
|
||||
using Dlhis.Basic.Device.Response;
|
||||
using Dlhis.Basic.Device.Services;
|
||||
using Dlhis.Basic.Packs;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -17,9 +17,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="6.0.26" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Basic.Organization.Services;
|
||||
using Dlhis.Basic.Packs;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
using Kurisu.AspNetCore.Utils;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Dlhis.Basic.Packs;
|
||||
|
||||
public class DataProtectionJobPack : BaseAppPack
|
||||
{
|
||||
public override bool IsBeforeUseRouting { get; }
|
||||
|
||||
public override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
var redisConnection = ConnectionMultiplexer.Connect(Configuration.GetSection($"{nameof(RedisOptions)}:{nameof(RedisOptions.ConnectionString)}").Value);
|
||||
services.AddDataProtection()
|
||||
.SetApplicationName("yiliantong")
|
||||
.PersistKeysToStackExchangeRedis(redisConnection, "DataProtection-Keys");
|
||||
}
|
||||
}
|
||||
@@ -69,98 +69,3 @@ public class SqlSugarPack : BaseAppPack
|
||||
faceDb.Client.CodeFirst.InitTables<GainfoFaceEntity>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 日志
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class LogAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public LogAttribute(string title)
|
||||
{
|
||||
Title = title;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否处理差异
|
||||
/// </summary>
|
||||
public bool Diff { get; set; }
|
||||
|
||||
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
PreSetting(context.HttpContext);
|
||||
await next();
|
||||
}
|
||||
|
||||
private void PreSetting(HttpContext httpContext)
|
||||
{
|
||||
var options = httpContext.RequestServices.GetService<ISqlSugarOptionsService>();
|
||||
|
||||
options.Title = Title;
|
||||
options.Diff = Diff;
|
||||
options.BatchNo = Guid.NewGuid();
|
||||
options.RoutePath = httpContext.Request.Path.Value;
|
||||
options.RaiseTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 事务
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class TransactionalAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
var dbContext = context.HttpContext.RequestServices.GetRequiredService<ISqlSugarClient>();
|
||||
await dbContext.Ado.BeginTranAsync();
|
||||
try
|
||||
{
|
||||
var result = await next();
|
||||
if (result.Exception != null)
|
||||
{
|
||||
throw result.Exception;
|
||||
}
|
||||
else
|
||||
{
|
||||
await dbContext.Ado.CommitTranAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await dbContext.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 忽略租户
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class IgnoreTenantAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
var dbContext = context.HttpContext.RequestServices.GetRequiredService<ISqlSugarClient>();
|
||||
var options = context.HttpContext!.RequestServices.GetService<ISqlSugarOptionsService>();
|
||||
try
|
||||
{
|
||||
dbContext.QueryFilter.ClearAndBackup<ITenantId>();
|
||||
options.IgnoreTenant = true;
|
||||
await next();
|
||||
}
|
||||
finally
|
||||
{
|
||||
options.IgnoreTenant = false;
|
||||
dbContext.QueryFilter.Restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,10 @@
|
||||
"Url": "https://yikatong.isawesome.cn/api/basic/gainfos/face?token=",
|
||||
"Limit": 7200
|
||||
},
|
||||
"DataProtectionOptions": {
|
||||
"Enable": true,
|
||||
"AppName": "yiliantong"
|
||||
},
|
||||
"SqlSugarOptions": {
|
||||
"DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;",
|
||||
"SlaveConnectionString": [],
|
||||
|
||||
@@ -36,8 +36,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.4" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.5" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.RemoteCall" Version="0.0.2" />
|
||||
<PackageReference Include="Kurisu.RemoteCall" Version="0.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.4" />
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.5" />
|
||||
<PackageReference Include="Minio" Version="6.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.SqlSugar" Version="0.1.1" />
|
||||
<PackageReference Include="Kurisu.SqlSugar" Version="0.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Dlhis.ScheduledTask.DeviceUploadLog.Request;
|
||||
using Dlhis.ScheduledTask.DeviceUploadLog.Response;
|
||||
using Dlhis.ScheduledTask.DeviceUploadLog.Services;
|
||||
using Dlhis.ScheduledTask.Packs;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -20,8 +20,7 @@
|
||||
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.7" />
|
||||
<PackageReference Include="Hangfire.Dashboard.BasicAuthorization" Version="1.0.2" />
|
||||
<PackageReference Include="Hangfire.Redis.StackExchange" Version="1.9.3" />
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.4" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="6.0.26" />
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
using Kurisu.AspNetCore.Utils;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Packs;
|
||||
|
||||
public class DataProtectionJobPack : BaseAppPack
|
||||
{
|
||||
public override bool IsBeforeUseRouting { get; }
|
||||
|
||||
public override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
var redisConnection = ConnectionMultiplexer.Connect(Configuration.GetSection($"{nameof(RedisOptions)}:{nameof(RedisOptions.ConnectionString)}").Value);
|
||||
services.AddDataProtection()
|
||||
.SetApplicationName("scheduled")
|
||||
.PersistKeysToStackExchangeRedis(redisConnection, "DataProtection-Keys");
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,5 @@
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
using Kurisu.Core.DataAccess.Entity;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Packs;
|
||||
|
||||
@@ -16,103 +12,3 @@ public class SqlSugarPack : BaseAppPack
|
||||
services.AddSqlSugar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 日志
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class LogAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public LogAttribute(string title)
|
||||
{
|
||||
Title = title;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否处理差异
|
||||
/// </summary>
|
||||
public bool Diff { get; set; }
|
||||
|
||||
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
PreSetting(context.HttpContext);
|
||||
await next();
|
||||
}
|
||||
|
||||
private void PreSetting(HttpContext httpContext)
|
||||
{
|
||||
var options = httpContext.RequestServices.GetService<ISqlSugarOptionsService>();
|
||||
|
||||
options.Title = Title;
|
||||
options.Diff = Diff;
|
||||
options.BatchNo = Guid.NewGuid();
|
||||
options.RoutePath = httpContext.Request.Path.Value;
|
||||
options.RaiseTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 事务
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class TransactionalAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
var dbContext = context.HttpContext.RequestServices.GetRequiredService<ISqlSugarClient>();
|
||||
await dbContext.Ado.BeginTranAsync();
|
||||
try
|
||||
{
|
||||
var result = await next();
|
||||
if (result.Exception != null)
|
||||
{
|
||||
throw result.Exception;
|
||||
}
|
||||
else
|
||||
{
|
||||
await dbContext.Ado.CommitTranAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await dbContext.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 忽略租户
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class IgnoreTenantAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
var dbContext = context.HttpContext.RequestServices.GetRequiredService<ISqlSugarClient>();
|
||||
var options = context.HttpContext!.RequestServices.GetService<ISqlSugarOptionsService>();
|
||||
try
|
||||
{
|
||||
dbContext.QueryFilter.ClearAndBackup<ITenantId>();
|
||||
options.IgnoreTenant = true;
|
||||
await next();
|
||||
}
|
||||
finally
|
||||
{
|
||||
options.IgnoreTenant = false;
|
||||
dbContext.QueryFilter.Restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,12 +23,6 @@ public class Startup : DefaultStartup
|
||||
{
|
||||
base.ConfigureServices(services);
|
||||
services.AddRedis();
|
||||
|
||||
var reidConnection = Configuration.GetSection($"{nameof(RedisOptions)}:{nameof(RedisOptions.ConnectionString)}").Value;
|
||||
var redis = ConnectionMultiplexer.Connect(reidConnection);
|
||||
services.AddDataProtection()
|
||||
.SetApplicationName("yiliantong")
|
||||
.PersistKeysToStackExchangeRedis(redis, "DataProtection-Keys");
|
||||
}
|
||||
|
||||
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "http://*:5010"
|
||||
"applicationUrl": "http://localhost:5010"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using Dlhis.ScheduledTask.Packs;
|
||||
using Dlhis.ScheduledTask.TaskAssignment.Request;
|
||||
using Dlhis.ScheduledTask.TaskAssignment.Request;
|
||||
using Dlhis.ScheduledTask.TaskAssignment.Response;
|
||||
using Dlhis.ScheduledTask.TaskAssignment.Services;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
|
||||
@@ -8,6 +8,10 @@
|
||||
"InternalRequest": {
|
||||
"SysRequestUrl": "http://sys"
|
||||
},
|
||||
"DataProtectionOptions": {
|
||||
"Enable": true,
|
||||
"AppName": "yiliantong"
|
||||
},
|
||||
"SqlSugarOptions": {
|
||||
"DefaultConnectionString": "server=192.168.199.124;port=3306;userid=root;password=dlhis123;database=yikatong;charset=utf8mb4;",
|
||||
"SlaveConnectionString": [],
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.RemoteCall" Version="0.0.2" />
|
||||
<PackageReference Include="Kurisu.RemoteCall" Version="0.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.4" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.5" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.4" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.4" />
|
||||
<PackageReference Include="Kurisu.AspNetCore" Version="0.5.5" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user