feat(api): в UnitWithAttributesResponse добавлены родительские и дочерние ЭК
This commit is contained in:
@@ -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; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user