forked from gongxuegit/tiku-backend.net
feat: add phase five operations foundation
This commit is contained in:
27
Tiku.Infrastructure/Backoffice/OperationAuditService.cs
Normal file
27
Tiku.Infrastructure/Backoffice/OperationAuditService.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Tiku.Application.Backoffice;
|
||||
using Tiku.Domain.Operations;
|
||||
using Tiku.Infrastructure.Persistence;
|
||||
|
||||
namespace Tiku.Infrastructure.Backoffice;
|
||||
|
||||
internal sealed class OperationAuditService(TikuDbContext dbContext) : IOperationAuditService
|
||||
{
|
||||
public async Task WriteAsync(
|
||||
BackofficeOperationAuditCommand command,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
dbContext.AuditLogs.Add(new AuditLog
|
||||
{
|
||||
TenantId = command.TenantId,
|
||||
ActorUserId = command.ActorUserId,
|
||||
Action = command.Action.Trim(),
|
||||
TargetType = command.TargetType?.Trim(),
|
||||
TargetId = command.TargetId?.Trim(),
|
||||
Details = command.Details,
|
||||
IpAddress = command.IpAddress,
|
||||
UserAgent = command.UserAgent
|
||||
});
|
||||
|
||||
await dbContext.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user