Merge branch 'abp' of https://gitee.com/ccnetcore/Yi into abp

This commit is contained in:
Xwen
2023-12-12 18:10:17 +08:00
15 changed files with 2500 additions and 46 deletions

View File

@@ -222,7 +222,7 @@ namespace Yi.Framework.SqlSugarCore
{ {
if (Options.EnabledSqlLog) if (Options.EnabledSqlLog)
{ {
Logger.CreateLogger<SqlSugarDbContext>().LogDebug(UtilMethods.GetSqlString(DbType.SqlServer, sql, pars)); Logger.CreateLogger<SqlSugarDbContext>().LogDebug("Yi-SQL执行:"+UtilMethods.GetSqlString(DbType.SqlServer, sql, pars));
} }
} }

View File

@@ -3,16 +3,24 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Volo.Abp.Auditing; using Volo.Abp.Auditing;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Yi.Framework.Core.Helper;
using Yi.Framework.SqlSugarCore.Abstractions;
namespace Yi.Framework.SqlSugarCore namespace Yi.Framework.SqlSugarCore
{ {
public class SqlSugarLogAuditingStore : IAuditingStore, ISingletonDependency public class SqlSugarLogAuditingStore : IAuditingStore, ISingletonDependency
{ {
private readonly ILogger<SqlSugarLogAuditingStore> _logger;
public SqlSugarLogAuditingStore(ILogger<SqlSugarLogAuditingStore> logger, ISqlSugarDbContext sqlSugarDbContext)
{
_logger= logger;
}
public Task SaveAsync(AuditLogInfo auditInfo) public Task SaveAsync(AuditLogInfo auditInfo)
{ {
//Console.WriteLine(auditInfo.ExecutionTime); _logger.LogDebug("Yi-请求追踪:"+JsonHelper.ObjToStr(auditInfo, "yyyy-MM-dd HH:mm:ss"));
return Task.CompletedTask; return Task.CompletedTask;
} }
} }

View File

@@ -15,11 +15,6 @@ namespace Yi.Framework.SqlSugarCore.Uow
public async Task CommitAsync(CancellationToken cancellationToken = default) public async Task CommitAsync(CancellationToken cancellationToken = default)
{ {
await Console.Out.WriteLineAsync("事务提交");
Console.WriteLine(_sqlsugarDbContext.SqlSugarClient.ContextID + "---------------");
await _sqlsugarDbContext.SqlSugarClient.Ado.CommitTranAsync(); await _sqlsugarDbContext.SqlSugarClient.Ado.CommitTranAsync();
} }
@@ -30,8 +25,6 @@ namespace Yi.Framework.SqlSugarCore.Uow
public async Task RollbackAsync(CancellationToken cancellationToken = default) public async Task RollbackAsync(CancellationToken cancellationToken = default)
{ {
await Console.Out.WriteLineAsync("事务回滚");
Console.WriteLine(_sqlsugarDbContext.SqlSugarClient.ContextID);
await _sqlsugarDbContext.SqlSugarClient.Ado.RollbackTranAsync(); await _sqlsugarDbContext.SqlSugarClient.Ado.RollbackTranAsync();
} }
} }

View File

@@ -2,7 +2,6 @@
{ {
public class AccessLogDto public class AccessLogDto
{ {
public Guid Id { get; set; }
public long Number { get; set; } public long Number { get; set; }
public DateTime? LastModificationTime { get; set; } public DateTime? LastModificationTime { get; set; }
public DateTime CreationTime { get; set; } public DateTime CreationTime { get; set; }

View File

@@ -5,7 +5,7 @@ namespace Yi.Framework.Bbs.Application.Contracts.Dtos.Discuss
{ {
public class DiscussGetListInputVo : PagedAndSortedResultRequestDto public class DiscussGetListInputVo : PagedAndSortedResultRequestDto
{ {
public string Title { get; set; } public string? Title { get; set; }
public Guid? PlateId { get; set; } public Guid? PlateId { get; set; }

View File

@@ -48,7 +48,7 @@ namespace Yi.Framework.Bbs.Application.Services
/// 触发 /// 触发
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[HttpPost("")] [HttpPost("access-log")]
public async Task AccessAsync() public async Task AccessAsync()
{ {
//可判断http重复防止同一ip多次访问 //可判断http重复防止同一ip多次访问

View File

@@ -3,17 +3,17 @@ using Volo.Abp.BackgroundWorkers.Quartz;
namespace Yi.Framework.Rbac.Application.Jobs namespace Yi.Framework.Rbac.Application.Jobs
{ {
public class TestJob : QuartzBackgroundWorkerBase //public class TestJob : QuartzBackgroundWorkerBase
{ //{
public TestJob() // public TestJob()
{ // {
JobDetail = JobBuilder.Create<TestJob>().WithIdentity(nameof(TestJob)).Build(); // JobDetail = JobBuilder.Create<TestJob>().WithIdentity(nameof(TestJob)).Build();
Trigger = TriggerBuilder.Create().WithIdentity(nameof(TestJob)).WithCronSchedule("* * * * * ? *").Build(); // Trigger = TriggerBuilder.Create().WithIdentity(nameof(TestJob)).WithCronSchedule("* * * * * ? *").Build();
} // }
public override Task Execute(IJobExecutionContext context) // public override Task Execute(IJobExecutionContext context)
{ // {
Console.WriteLine("你好,世界"); // Console.WriteLine("你好,世界");
return Task.CompletedTask; // return Task.CompletedTask;
} // }
} //}
} }

View File

@@ -29,7 +29,6 @@ namespace Yi.Framework.Rbac.Application
public async override Task OnApplicationInitializationAsync(ApplicationInitializationContext context) public async override Task OnApplicationInitializationAsync(ApplicationInitializationContext context)
{ {
//await context.AddBackgroundWorkerAsync<TestJob>();
} }
} }
} }

View File

@@ -28,11 +28,7 @@ namespace Yi.Abp.SqlSugarCore
protected override void OnLogExecuting(string sql, SugarParameter[] pars) protected override void OnLogExecuting(string sql, SugarParameter[] pars)
{ {
//获取原生SQL推荐 5.1.4.63 性能OK base.OnLogExecuting(sql, pars);
//UtilMethods.GetNativeSql(sql,pars)
//获取无参数化SQL 影响性能只适合调试
this.Logger.CreateLogger<YiDbContext>().LogInformation(UtilMethods.GetSqlString(DbType.SqlServer, sql, pars));
} }
protected override void OnLogExecuted(string sql, SugarParameter[] pars) protected override void OnLogExecuted(string sql, SugarParameter[] pars)

File diff suppressed because it is too large Load Diff

View File

@@ -1,9 +1,36 @@
using Serilog;
using Serilog.Events;
using Yi.Abp.Web; using Yi.Abp.Web;
var builder = WebApplication.CreateBuilder(args); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־,<2C><>ʹ<EFBFBD><CAB9>{SourceContext}<7D><>¼
builder.WebHost.UseUrls(builder.Configuration["App:SelfUrl"]); Log.Logger = new LoggerConfiguration()
builder.Host.UseAutofac(); .MinimumLevel.Debug()
await builder.Services.AddApplicationAsync<YiAbpWebModule>(); .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
var app = builder.Build(); .MinimumLevel.Override("Microsoft.AspNetCore.Hosting.Diagnostics",LogEventLevel.Error)
await app.InitializeApplicationAsync(); .MinimumLevel.Override("Quartz", LogEventLevel.Warning)
await app.RunAsync(); .Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/log-.txt", rollingInterval: RollingInterval.Day))
.WriteTo.Async(c => c.Console())
.CreateLogger();
try
{
Log.Information("Yi<59><69><EFBFBD><EFBFBD>-Abp.vNext<78><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseUrls(builder.Configuration["App:SelfUrl"]);
builder.Host.UseAutofac();
builder.Host.UseSerilog();
await builder.Services.AddApplicationAsync<YiAbpWebModule>();
var app = builder.Build();
await app.InitializeApplicationAsync();
await app.RunAsync();
}
catch (Exception ex)
{
Log.Fatal(ex, "Yi<59><69><EFBFBD><EFBFBD>-Abp.vNext<78><74><EFBFBD><EFBFBD>ը<EFBFBD><D5A8>");
}
finally
{
Log.CloseAndFlush();
}

View File

@@ -10,6 +10,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.14" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.14" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.12" /> <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.12" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="7.4.2" /> <PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" Version="7.4.2" />
<PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="7.4.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Mvc" Version="7.4.1" />
<PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="7.4.1" /> <PackageReference Include="Volo.Abp.AspNetCore.Serilog" Version="7.4.1" />

View File

@@ -10,7 +10,6 @@ using Volo.Abp.AspNetCore.Mvc.AntiForgery;
using Volo.Abp.AspNetCore.Serilog; using Volo.Abp.AspNetCore.Serilog;
using Volo.Abp.Auditing; using Volo.Abp.Auditing;
using Volo.Abp.Autofac; using Volo.Abp.Autofac;
using Volo.Abp.Json;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.Swashbuckle; using Volo.Abp.Swashbuckle;
using Yi.Abp.Application; using Yi.Abp.Application;
@@ -25,7 +24,7 @@ using Yi.Framework.Rbac.Domain.Shared.Options;
namespace Yi.Abp.Web namespace Yi.Abp.Web
{ {
[DependsOn( [DependsOn(
typeof(YiAbpSqlSugarCoreModule), typeof(YiAbpSqlSugarCoreModule),
typeof(YiAbpApplicationModule), typeof(YiAbpApplicationModule),
typeof(AbpAspNetCoreMvcModule), typeof(AbpAspNetCoreMvcModule),
@@ -43,6 +42,7 @@ namespace Yi.Abp.Web
public override Task ConfigureServicesAsync(ServiceConfigurationContext context) public override Task ConfigureServicesAsync(ServiceConfigurationContext context)
{ {
var configuration = context.Services.GetConfiguration(); var configuration = context.Services.GetConfiguration();
var host = context.Services.GetHostingEnvironment();
var service = context.Services; var service = context.Services;
//请求日志 //请求日志
@@ -65,10 +65,7 @@ namespace Yi.Abp.Web
{ {
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
}); });
Configure<AbpJsonOptions>(options =>
{
options.OutputDateTimeFormat = "yyyy-MM-dd HH:mm:ss";
});
Configure<AbpAntiForgeryOptions>(options => Configure<AbpAntiForgeryOptions>(options =>
{ {
options.AutoValidate = false; options.AutoValidate = false;
@@ -77,7 +74,7 @@ namespace Yi.Abp.Web
//Swagger //Swagger
context.Services.AddYiSwaggerGen<YiAbpWebModule>(options => context.Services.AddYiSwaggerGen<YiAbpWebModule>(options =>
{ {
options.SwaggerDoc("default", new OpenApiInfo { Title = "Yi.Framework.Abp", Version = "v1",Description="集大成者" }); options.SwaggerDoc("default", new OpenApiInfo { Title = "Yi.Framework.Abp", Version = "v1", Description = "集大成者" });
}); });
//跨域 //跨域
@@ -145,7 +142,6 @@ namespace Yi.Abp.Web
var env = context.GetEnvironment(); var env = context.GetEnvironment();
var app = context.GetApplicationBuilder(); var app = context.GetApplicationBuilder();
app.UseRouting(); app.UseRouting();
//跨域 //跨域

1160
Yi.Bbs.Vue3/yarn.lock Normal file

File diff suppressed because it is too large Load Diff