Skip to content

Commit

Permalink
add ouAduitProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrytang67 committed Jun 6, 2020
1 parent aab2beb commit 3cab308
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public override void ConfigureServices(ServiceConfigurationContext context)
{
options.ValueProviders.Add<GlobalAuditValueProvider>();
options.ValueProviders.Add<TenantAuditValueProvider>();
options.ValueProviders.Add<OrganizationUnitAuditValueProvider>();
options.ValueProviders.Add<ShopAuditValueProvider>();
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using TT.Abp.AuditManagement.Domain;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Uow;

namespace TT.Abp.AuditManagement.Audits
{
public class OrganizationUnitAuditValueProvider : AuditValueProvider
{
public const string ProviderName = "O";

public override string Name => ProviderName;

public OrganizationUnitAuditValueProvider(
IRepository<AuditFlow, Guid> auditFlowRepository
) : base(auditFlowRepository)
{
}

[UnitOfWork]
public override async Task<Guid?> GetOrNullAsync(AuditDefinition audit)
{
var dbEntity = await AuditFlowRepository
.FirstOrDefaultAsync(
x => x.ProviderName == ProviderName
&& x.AuditName == audit.Name
&& x.Enable
&& x.ProviderKey == "ouId"
);

return dbEntity?.Id;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task ValueProviderTest()
var providers = _auditValueProvider.Providers;

// define in mall Module
providers.Count.ShouldBe(3);
providers.Count.ShouldBe(4);

await Task.CompletedTask;
}
Expand Down

0 comments on commit 3cab308

Please sign in to comment.