feat(dal,api): добавлен индекс в таблицу UnitInValues. В api изменены респонсы Template и Unit.
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
public int? MaxValueRelationships { get; set; }
|
public int? MaxValueRelationships { get; set; }
|
||||||
|
|
||||||
public bool? isParentRelationships { get; set; }
|
public bool? IsParentRelationships { get; set; }
|
||||||
|
|
||||||
public required string TemplateNameMask { get; set; }
|
public required string TemplateNameMask { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,8 @@
|
|||||||
|
|
||||||
public bool IsAutoDistributionEnabled { get; set; }
|
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; }
|
public JobResponse? Job { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Response с всеми аттребутами и их значениями
|
/// Response со всеми аттребутами и их значениями
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UnitWithAttributesResponse : UnitResponse
|
public class UnitWithAttributesResponse : UnitResponse
|
||||||
{
|
{
|
||||||
@@ -24,6 +24,13 @@
|
|||||||
|
|
||||||
public List<AttributeResponse>? Attributes { get; set; }
|
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>? Parents { get; set; }
|
||||||
|
|
||||||
public List<UnitResponse>? Childrens { get; set; }
|
public List<UnitResponse>? Childrens { get; set; }
|
||||||
|
|||||||
@@ -249,9 +249,9 @@ namespace PARR.API.Controllers.V1
|
|||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orig.IsParentRelationships != request.isParentRelationships)
|
if (orig.IsParentRelationships != request.IsParentRelationships)
|
||||||
{
|
{
|
||||||
orig.IsParentRelationships = request.isParentRelationships;
|
orig.IsParentRelationships = request.IsParentRelationships;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,8 +62,11 @@ namespace PARR.API.Controllers.V1
|
|||||||
if (!units.Any())
|
if (!units.Any())
|
||||||
return NoContent();
|
return NoContent();
|
||||||
|
|
||||||
var unitResponse = mapper.Map<List<UnitWithAttributesResponse>>(units);
|
//var unitResponse = mapper.Map<List<UnitWithAttributesResponse>>(units);
|
||||||
var paginationResponse = new PagedResponse<UnitWithAttributesResponse>(unitResponse, true).GetPaginatedProps(paginationFilter, query);
|
//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);
|
return Ok(paginationResponse);
|
||||||
}
|
}
|
||||||
@@ -89,9 +92,13 @@ namespace PARR.API.Controllers.V1
|
|||||||
if (unit == null)
|
if (unit == null)
|
||||||
return NotFound();
|
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>()
|
CreateMap<Unit, UnitResponse>()
|
||||||
.Include<Unit, UnitWithAttributesResponse>()
|
.Include<Unit, UnitWithAttributesResponse>()
|
||||||
|
.Include<Unit, UnitRelationshipsAndAttributesResponse>()
|
||||||
.ForMember(d => d.Name, o => o.MapFrom(s => s.Name));
|
.ForMember(d => d.Name, o => o.MapFrom(s => s.Name));
|
||||||
|
|
||||||
|
|
||||||
CreateMap<Unit, UnitWithAttributesResponse>()
|
CreateMap<Unit, UnitWithAttributesResponse>()
|
||||||
.ForMember(d => d.Childrens, o => o.MapFrom(s => s.ChildUnits.Select(t => t.ChildUnit).OrderBy(t => t.Name)))
|
.Include<Unit, UnitRelationshipsAndAttributesResponse>()
|
||||||
.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)
|
.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,
|
||||||
Id = fieldGroup.Key!.Id,
|
IsMultipleValue = fieldGroup.Key.IsMultipleValue
|
||||||
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()
|
||||||
},
|
}
|
||||||
Values = fieldGroup.Select(s => new UnitFieldValueResponse { Id = s.ValueId, Value = s.Value!.Value }).ToList()
|
|
||||||
}
|
|
||||||
).OrderBy(o => o.Field.Name)
|
).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
|
#endregion
|
||||||
|
|
||||||
#region WorkGroup
|
#region WorkGroup
|
||||||
|
|||||||
3967
PARR.DAL/Migrations/20251121002115_tbkUnitInValueAddIndexes.Designer.cs
generated
Normal file
3967
PARR.DAL/Migrations/20251121002115_tbkUnitInValueAddIndexes.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,40 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace PARR.DAL.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class tbkUnitInValueAddIndexes : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_UnitInValues_FieldId",
|
||||||
|
schema: "unit",
|
||||||
|
table: "UnitInValues");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_UnitInValues_FieldId_ValueId",
|
||||||
|
schema: "unit",
|
||||||
|
table: "UnitInValues",
|
||||||
|
columns: new[] { "FieldId", "ValueId" });
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_UnitInValues_FieldId_ValueId",
|
||||||
|
schema: "unit",
|
||||||
|
table: "UnitInValues");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_UnitInValues_FieldId",
|
||||||
|
schema: "unit",
|
||||||
|
table: "UnitInValues",
|
||||||
|
column: "FieldId");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2980,10 +2980,10 @@ namespace PARR.DAL.Migrations
|
|||||||
|
|
||||||
b.HasKey("UnitId", "FieldId", "ValueId");
|
b.HasKey("UnitId", "FieldId", "ValueId");
|
||||||
|
|
||||||
b.HasIndex("FieldId");
|
|
||||||
|
|
||||||
b.HasIndex("ValueId");
|
b.HasIndex("ValueId");
|
||||||
|
|
||||||
|
b.HasIndex("FieldId", "ValueId");
|
||||||
|
|
||||||
b.ToTable("UnitInValues", "unit", t =>
|
b.ToTable("UnitInValues", "unit", t =>
|
||||||
{
|
{
|
||||||
t.HasComment("Таблица связи ЭК с полями и со значениями");
|
t.HasComment("Таблица связи ЭК с полями и со значениями");
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace PARR.DAL.Models.Unit
|
|||||||
[Table("UnitInValues", Schema = DataContextSettings.Unit)]
|
[Table("UnitInValues", Schema = DataContextSettings.Unit)]
|
||||||
[Comment("Таблица связи ЭК с полями и со значениями")]
|
[Comment("Таблица связи ЭК с полями и со значениями")]
|
||||||
[PrimaryKey(nameof(UnitId), nameof(FieldId), nameof(ValueId))]
|
[PrimaryKey(nameof(UnitId), nameof(FieldId), nameof(ValueId))]
|
||||||
|
[Index(nameof(FieldId), nameof(ValueId))]
|
||||||
public class UnitInValue : IBaseDateModified, IBaseDateCreated
|
public class UnitInValue : IBaseDateModified, IBaseDateCreated
|
||||||
{
|
{
|
||||||
public Guid UnitId { get; set; }
|
public Guid UnitId { get; set; }
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
<DockerServiceName>parr.api</DockerServiceName>
|
<DockerServiceName>parr.api</DockerServiceName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="docker-compose.template-matcher.yml" />
|
||||||
<None Include="docker-compose.template-task-generator.yml" />
|
<None Include="docker-compose.template-task-generator.yml" />
|
||||||
<None Include="docker-compose.template-generator.yml" />
|
<None Include="docker-compose.template-generator.yml" />
|
||||||
<None Include="docker-compose.aihit-loader.yml" />
|
<None Include="docker-compose.aihit-loader.yml" />
|
||||||
|
|||||||
Reference in New Issue
Block a user