using MyHomePage.Api.Models.Entities;
using MyHomePage.Api.Infrastructure.Database;
using SqlSugar;
namespace MyHomePage.Api.Services;
/// 同步日志写入助手:增删改实体时统一调用。
public class SyncLogHelper
{
private readonly ISqlSugarClient _db;
public SyncLogHelper(ISqlSugarClient db) => _db = db;
/// 写入一条同步日志
public Task WriteAsync(string entityType, int entityId, string operation)
{
return _db.Insertable(new SyncLog
{
EntityType = entityType,
EntityId = entityId,
Operation = operation,
Timestamp = DateTime.UtcNow
}).ExecuteCommandAsync();
}
}