feat(infra): IUsuarioRepository.UpdatePermisosJsonAsync + impl Dapper [UDT-009]
This commit is contained in:
@@ -17,4 +17,7 @@ public interface IUsuarioRepository
|
||||
Task UpdateAsync(int id, UpdateUsuarioFields fields, DateTime fechaModificacion, CancellationToken ct = default);
|
||||
Task UpdatePasswordAsync(int id, string passwordHash, bool mustChangePassword, CancellationToken ct = default);
|
||||
Task<int> CountActiveAdminsAsync(CancellationToken ct = default);
|
||||
|
||||
// UDT-009
|
||||
Task UpdatePermisosJsonAsync(int id, string permisosJson, DateTime fechaModificacion, CancellationToken ct = default);
|
||||
}
|
||||
|
||||
@@ -226,6 +226,27 @@ public sealed class UsuarioRepository : IUsuarioRepository
|
||||
return await connection.ExecuteScalarAsync<int>(sql);
|
||||
}
|
||||
|
||||
// UDT-009 ─────────────────────────────────────────────────────────────────
|
||||
|
||||
public async Task UpdatePermisosJsonAsync(int id, string permisosJson, DateTime fechaModificacion, CancellationToken ct = default)
|
||||
{
|
||||
const string sql = """
|
||||
UPDATE dbo.Usuario
|
||||
SET PermisosJson = @PermisosJson,
|
||||
FechaModificacion = @FechaModificacion
|
||||
WHERE Id = @Id
|
||||
""";
|
||||
|
||||
await using var connection = _connectionFactory.CreateConnection();
|
||||
await connection.OpenAsync(ct);
|
||||
await connection.ExecuteAsync(sql, new
|
||||
{
|
||||
PermisosJson = permisosJson,
|
||||
FechaModificacion = fechaModificacion,
|
||||
Id = id
|
||||
});
|
||||
}
|
||||
|
||||
// ── mapping ───────────────────────────────────────────────────────────────
|
||||
|
||||
private static Usuario MapRow(UsuarioRow row)
|
||||
|
||||
Reference in New Issue
Block a user