feat(application): RubroTreeBuilder + GetRubroTree con tieneAvisos (CAT-002)
This commit is contained in:
@@ -12,7 +12,8 @@ public static class RubroTreeBuilder
|
||||
{
|
||||
public static IReadOnlyList<RubroTreeNodeDto> Build(
|
||||
IEnumerable<Rubro> flat,
|
||||
bool incluirInactivos)
|
||||
bool incluirInactivos,
|
||||
IReadOnlyDictionary<int, int> avisoCounts)
|
||||
{
|
||||
var filtered = incluirInactivos
|
||||
? flat.ToList()
|
||||
@@ -36,6 +37,7 @@ public static class RubroTreeBuilder
|
||||
Activo: r.Activo,
|
||||
ParentId: r.ParentId,
|
||||
TarifarioBaseId: r.TarifarioBaseId,
|
||||
TieneAvisos: avisoCounts.GetValueOrDefault(r.Id, 0) > 0,
|
||||
Hijos: children);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,4 +10,5 @@ public sealed record RubroTreeNodeDto(
|
||||
bool Activo,
|
||||
int? ParentId,
|
||||
int? TarifarioBaseId,
|
||||
bool TieneAvisos,
|
||||
IReadOnlyList<RubroTreeNodeDto> Hijos);
|
||||
|
||||
@@ -17,6 +17,7 @@ public sealed class GetRubroTreeQueryHandler : ICommandHandler<GetRubroTreeQuery
|
||||
public async Task<IReadOnlyList<RubroTreeNodeDto>> Handle(GetRubroTreeQuery query)
|
||||
{
|
||||
var all = await _repo.GetAllAsync(query.IncluirInactivos);
|
||||
return RubroTreeBuilder.Build(all, query.IncluirInactivos);
|
||||
// CAT-002: avisoCounts injected via IAvisoQueryRepository (wired in Batch 6)
|
||||
return RubroTreeBuilder.Build(all, query.IncluirInactivos, new Dictionary<int, int>());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user