feat(dal,api): добавлен индекс в таблицу UnitInValues. В api изменены респонсы Template и Unit.
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
|
||||
public int? MaxValueRelationships { get; set; }
|
||||
|
||||
public bool? isParentRelationships { get; set; }
|
||||
public bool? IsParentRelationships { get; set; }
|
||||
|
||||
public required string TemplateNameMask { get; set; }
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@
|
||||
|
||||
public bool IsAutoDistributionEnabled { get; set; }
|
||||
|
||||
public UnitResponse? Unit { get; set; }
|
||||
//public UnitResponse? Unit { get; set; }
|
||||
public UnitWithAttributesResponse? Unit { get; set; }
|
||||
|
||||
public JobResponse? Job { get; set; }
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Response с всеми аттребутами и их значениями
|
||||
/// Response со всеми аттребутами и их значениями
|
||||
/// </summary>
|
||||
public class UnitWithAttributesResponse : UnitResponse
|
||||
{
|
||||
@@ -24,6 +24,13 @@
|
||||
|
||||
public List<AttributeResponse>? Attributes { get; set; }
|
||||
|
||||
//public List<UnitResponse>? Parents { get; set; }
|
||||
|
||||
//public List<UnitResponse>? Childrens { get; set; }
|
||||
}
|
||||
|
||||
public class UnitRelationshipsAndAttributesResponse : UnitWithAttributesResponse
|
||||
{
|
||||
public List<UnitResponse>? Parents { get; set; }
|
||||
|
||||
public List<UnitResponse>? Childrens { get; set; }
|
||||
|
||||
@@ -249,9 +249,9 @@ namespace PARR.API.Controllers.V1
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (orig.IsParentRelationships != request.isParentRelationships)
|
||||
if (orig.IsParentRelationships != request.IsParentRelationships)
|
||||
{
|
||||
orig.IsParentRelationships = request.isParentRelationships;
|
||||
orig.IsParentRelationships = request.IsParentRelationships;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,8 +62,11 @@ namespace PARR.API.Controllers.V1
|
||||
if (!units.Any())
|
||||
return NoContent();
|
||||
|
||||
var unitResponse = mapper.Map<List<UnitWithAttributesResponse>>(units);
|
||||
var paginationResponse = new PagedResponse<UnitWithAttributesResponse>(unitResponse, true).GetPaginatedProps(paginationFilter, query);
|
||||
//var unitResponse = mapper.Map<List<UnitWithAttributesResponse>>(units);
|
||||
//var paginationResponse = new PagedResponse<UnitWithAttributesResponse>(unitResponse, true).GetPaginatedProps(paginationFilter, query);
|
||||
|
||||
var unitResponse = mapper.Map<List<UnitRelationshipsAndAttributesResponse>>(units);
|
||||
var paginationResponse = new PagedResponse<UnitRelationshipsAndAttributesResponse>(unitResponse, true).GetPaginatedProps(paginationFilter, query);
|
||||
|
||||
return Ok(paginationResponse);
|
||||
}
|
||||
@@ -89,9 +92,13 @@ namespace PARR.API.Controllers.V1
|
||||
if (unit == null)
|
||||
return NotFound();
|
||||
|
||||
var response = mapper.Map<UnitWithAttributesResponse>(unit);
|
||||
//var response = mapper.Map<UnitWithAttributesResponse>(unit);
|
||||
|
||||
return Ok(new Response<UnitWithAttributesResponse>(response, true));
|
||||
//return Ok(new Response<UnitWithAttributesResponse>(response, true));
|
||||
|
||||
var response = mapper.Map<UnitRelationshipsAndAttributesResponse>(unit);
|
||||
|
||||
return Ok(new Response<UnitRelationshipsAndAttributesResponse>(response, true));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user