Files
tiku-backend.net/Tiku.Infrastructure/Backoffice/OperationAuditService.cs
xiong 33375a38d7
Some checks failed
ci / release-gate (push) Has been cancelled
refactor(architecture): harden module boundaries
2026-08-04 12:10:36 +08:00

27 lines
895 B
C#

using Tiku.Application.Backoffice;
using Tiku.Domain.Operations;
using Tiku.Infrastructure.Persistence;
namespace Tiku.Infrastructure.Backoffice;
internal sealed class OperationAuditService(IJobsOperationsPersistence 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);
}
}