Files
tiku-backend.net/Tiku.Infrastructure/Backoffice/OperationAuditService.cs
xiong c497a3ca8d
Some checks failed
ci / release-gate (push) Has been cancelled
清理代码
2026-08-03 12:31:39 +08:00

27 lines
882 B
C#

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);
}
}