feat(dal,api): добавлен индекс в таблицу UnitInValues. В api изменены респонсы Template и Unit.

This commit is contained in:
Mikhail Trubnikov
2025-11-21 10:56:30 +10:00
parent 240d292cee
commit ddbae48973
11 changed files with 4063 additions and 23 deletions

View File

@@ -114,25 +114,41 @@ namespace PARR.API.MappingProfiles
CreateMap<Unit, UnitResponse>()
.Include<Unit, UnitWithAttributesResponse>()
.Include<Unit, UnitRelationshipsAndAttributesResponse>()
.ForMember(d => d.Name, o => o.MapFrom(s => s.Name));
CreateMap<Unit, UnitWithAttributesResponse>()
.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)))
.Include<Unit, UnitRelationshipsAndAttributesResponse>()
.ForMember(d => d.Attributes, o => o.MapFrom(s => s.UnitValues.GroupBy(g => g.Field)
.Select(fieldGroup => new AttributeResponse
.Select(fieldGroup => new AttributeResponse
{
Field = new FieldResponse
{
Field = new FieldResponse
{
Id = fieldGroup.Key!.Id,
Name = string.IsNullOrEmpty(fieldGroup.Key.DisplayName) ? fieldGroup.Key.AihitName : fieldGroup.Key.DisplayName,
IsMultipleValue = fieldGroup.Key.IsMultipleValue
},
Values = fieldGroup.Select(s => new UnitFieldValueResponse { Id = s.ValueId, Value = s.Value!.Value }).ToList()
}
Id = fieldGroup.Key!.Id,
Name = string.IsNullOrEmpty(fieldGroup.Key.DisplayName) ? fieldGroup.Key.AihitName : fieldGroup.Key.DisplayName,
IsMultipleValue = fieldGroup.Key.IsMultipleValue
},
Values = fieldGroup.Select(s => new UnitFieldValueResponse { Id = s.ValueId, Value = s.Value!.Value }).ToList()
}
).OrderBy(o => o.Field.Name)
));
CreateMap<Unit, UnitRelationshipsAndAttributesResponse>()
.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)));
//.ForMember(d => d.Attributes, o => o.MapFrom(s => s.UnitValues.GroupBy(g => g.Field)
// .Select(fieldGroup => new AttributeResponse
// {
// Field = new FieldResponse
// {
// Id = fieldGroup.Key!.Id,
// Name = string.IsNullOrEmpty(fieldGroup.Key.DisplayName) ? fieldGroup.Key.AihitName : fieldGroup.Key.DisplayName,
// IsMultipleValue = fieldGroup.Key.IsMultipleValue
// },
// Values = fieldGroup.Select(s => new UnitFieldValueResponse { Id = s.ValueId, Value = s.Value!.Value }).ToList()
// }
// ).OrderBy(o => o.Field.Name)
//));
#endregion
#region WorkGroup