Skip to content

Commit 40e4953

Browse files
committed
fix: 修复工作单元传递审计信息问题
1 parent 7b07c97 commit 40e4953

File tree

5 files changed

+42
-6
lines changed

5 files changed

+42
-6
lines changed

framework/src/Bing.Datas.EntityFramework/Core/UnitOfWorkBase.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,8 @@ protected virtual void SaveChangesBefore()
452452
/// <param name="entry">输入实体</param>
453453
protected virtual void ApplyInterceptForAddedEntity(EntityEntry entry)
454454
{
455-
AuditPropertySetter?.SetCreationProperties(entry);
456-
AuditPropertySetter?.SetModificationProperties(entry);
455+
AuditPropertySetter?.SetCreationProperties(entry.Entity);
456+
AuditPropertySetter?.SetModificationProperties(entry.Entity);
457457
//SetCreationAudited(entry);
458458
//SetModificationAudited(entry);
459459
SetVersion(entry);
@@ -469,7 +469,7 @@ protected virtual void ApplyInterceptForAddedEntity(EntityEntry entry)
469469
/// <param name="entry">输入实体</param>
470470
protected virtual void ApplyInterceptForModifiedEntity(EntityEntry entry)
471471
{
472-
AuditPropertySetter?.SetModificationProperties(entry);
472+
AuditPropertySetter?.SetModificationProperties(entry.Entity);
473473
//SetModificationAudited(entry);
474474
SetVersion(entry);
475475
}
@@ -484,8 +484,8 @@ protected virtual void ApplyInterceptForModifiedEntity(EntityEntry entry)
484484
/// <param name="entry">输入实体</param>
485485
protected virtual void ApplyInterceptForDeletedEntity(EntityEntry entry)
486486
{
487-
AuditPropertySetter?.SetDeletionProperties(entry);
488-
AuditPropertySetter?.SetModificationProperties(entry);
487+
AuditPropertySetter?.SetDeletionProperties(entry.Entity);
488+
AuditPropertySetter?.SetModificationProperties(entry.Entity);
489489
SetVersion(entry);
490490
//SetModificationAudited(entry);
491491
}

modules/admin/src/Bing.Admin/Apis/TestController.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Threading.Tasks;
1+
using System;
2+
using System.Threading.Tasks;
23
using Bing.Admin.Data;
34
using Bing.Admin.Service.Abstractions;
45
using Bing.Admin.Systems.Domain.Events;
@@ -165,5 +166,34 @@ public Task<IActionResult> TestLoggerAsync(string text)
165166
.LogWarning();
166167
return Task.FromResult(Success());
167168
}
169+
170+
/// <summary>
171+
/// 测试GUID
172+
/// </summary>
173+
/// <param name="id"></param>
174+
[AllowAnonymous]
175+
[HttpGet("testGuid")]
176+
public IActionResult TestGuid(Guid id)
177+
{
178+
return Success(id);
179+
}
180+
181+
/// <summary>
182+
/// 测试 GUID 模型
183+
/// </summary>
184+
/// <param name="request"></param>
185+
[AllowAnonymous]
186+
[HttpGet("testGuidModel")]
187+
public IActionResult TestGuidModel([FromQuery] TestNullableGuidRequest request)
188+
{
189+
return Success(request.TestId);
190+
}
191+
192+
public class TestNullableGuidRequest
193+
{
194+
public Guid? TestId { get; set; }
195+
196+
public Guid? TestId2 { get; set; }
197+
}
168198
}
169199
}

modules/admin/src/Bing.Admin/Bing.Admin.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
66
<RootNamespace>Bing.Admin</RootNamespace>
7+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
78
</PropertyGroup>
89

910
<ItemGroup>

modules/admin/src/Bing.Admin/Modules/AppModule.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.ComponentModel;
2+
using System.Globalization;
23
using System.Text;
34
using AspectCore.Configuration;
45
using Bing.AspNetCore;
@@ -14,6 +15,7 @@
1415
using Bing.Tracing;
1516
using Microsoft.AspNetCore.Builder;
1617
using Microsoft.AspNetCore.Http;
18+
using Microsoft.AspNetCore.Localization;
1719
using Microsoft.AspNetCore.Mvc;
1820
using Microsoft.AspNetCore.Mvc.ApplicationModels;
1921
using Microsoft.AspNetCore.Mvc.Authorization;
@@ -49,6 +51,8 @@ public override IServiceCollection AddServices(IServiceCollection services)
4951
o.Filters.Add<ResultHandlerAttribute>();
5052
o.Filters.Add<BingExceptionFilter>();
5153
o.Conventions.Add(new AuthorizeControllerModelConvention());
54+
o.ModelBindingMessageProvider
55+
.SetNonPropertyAttemptedValueIsInvalidAccessor((x) => $"'{x}' 是不合法的参数");
5256
})
5357
.AddControllersAsServices()// 解决属性注入无法在控制器中注入的问题
5458
.AddNewtonsoftJson(options =>

modules/admin/src/Bing.Admin/Modules/SwaggerModule.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ public override void UseModule(IApplicationBuilder app)
9999
{
100100
UseSwaggerUI(config);
101101
config.UseDefaultSwaggerUI();
102+
config.EnableValidator(null);
102103
config.UseTokenStorage("oauth2");
103104
};
104105
});

0 commit comments

Comments
 (0)