feat(api): в UnitWithAttributesResponse добавлены родительские и дочерние ЭК

This commit is contained in:
Mikhail Trubnikov
2025-08-27 10:43:33 +10:00
parent b288888d7a
commit c9159f6546
3 changed files with 12 additions and 2 deletions

View File

@@ -23,6 +23,10 @@
public DateTimeOffset? LastLogon { get; set; }
public List<AttributeResponse>? Attributes { get; set; }
public List<UnitBaseResponse>? Parents { get; set; }
public List<UnitBaseResponse>? Childrens { get; set; }
}
}

View File

@@ -53,7 +53,9 @@ namespace PARR.API.Controllers.V1
.Include(t => t.UnitValues)
.ThenInclude(uv => uv.Value)
.Include(tf => tf.UnitValues)
.ThenInclude(uv => uv.Field);
.ThenInclude(uv => uv.Field)
.Include(p => p.ParentUnits).ThenInclude(t=>t.ParentUnit)
.Include(c => c.ChildUnits).ThenInclude(t=>t.ChildUnit);
var units = await unitService.GetPage(query, paginationFilter).ToListAsync();
@@ -80,6 +82,8 @@ namespace PARR.API.Controllers.V1
.ThenInclude(uv => uv.Value)
.Include(tf => tf.UnitValues)
.ThenInclude(uv => uv.Field)
.Include(p => p.ParentUnits).ThenInclude(t => t.ParentUnit)
.Include(c => c.ChildUnits).ThenInclude(t => t.ChildUnit)
.FirstOrDefaultAsync(t => t.Id == id);
if (unit == null)

View File

@@ -119,7 +119,9 @@ namespace PARR.API.MappingProfiles
.ForMember(d => d.Name, o => o.MapFrom(s => s.Name));
CreateMap<Unit, UnitWithAttributesResponse>()
.ForMember(d => d.Attributes, o => o.MapFrom(s => s.UnitValues!.OrderBy(s => (string.IsNullOrEmpty(s.Field!.DisplayName)) ? s.Field!.AihitName : s.Field!.DisplayName)));
.ForMember(d => d.Attributes, o => o.MapFrom(s => s.UnitValues!.OrderBy(s => (string.IsNullOrEmpty(s.Field!.DisplayName)) ? s.Field!.AihitName : s.Field!.DisplayName)))
.ForMember(d => d.Childrens, o => o.MapFrom(s => s.ChildUnits.Select(t => t.ChildUnit).OrderBy(t => t.Name)))
.ForMember(d => d.Parents, o => o.MapFrom(s => s.ParentUnits.Select(t => t.ParentUnit).OrderBy(t => t.Name)));
#endregion
#region WorkGroup