feat(api): в сущность FIeld добавлено поле IsMultipleValue для реализации записи повторяющихся полей, как сервер приложений в компонентном составе виртуальных серверов
This commit is contained in:
@@ -10,6 +10,6 @@
|
||||
/// <summary>
|
||||
/// Соответствующее полю значение
|
||||
/// </summary>
|
||||
public required UnitFieldValueResponse Value { get; set; }
|
||||
public required List<UnitFieldValueResponse> Values { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public required string Name { get; set; }
|
||||
|
||||
public bool? IsMultipleValue { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace PARR.API.Controllers.V1
|
||||
query = query
|
||||
.Include(t => t.UnitFilters)
|
||||
.ThenInclude(t => t.FieldFilters)
|
||||
.ThenInclude(t => t.Field)
|
||||
.ThenInclude(t => t.UnitField)
|
||||
.Include(t => t.UnitFilters)
|
||||
.ThenInclude(t => t.RelationshipFilters)
|
||||
.ThenInclude(t => t.UnitField);
|
||||
@@ -126,7 +126,7 @@ namespace PARR.API.Controllers.V1
|
||||
.Include(t => t.Group)
|
||||
.Include(t => t.UnitFilters)
|
||||
.ThenInclude(t => t.FieldFilters)
|
||||
.ThenInclude(t => t.Field)
|
||||
.ThenInclude(t => t.UnitField)
|
||||
.Include(t => t.UnitFilters)
|
||||
.ThenInclude(t => t.RelationshipFilters)
|
||||
.FirstOrDefaultAsync(t => t.Id == id);
|
||||
@@ -186,7 +186,7 @@ namespace PARR.API.Controllers.V1
|
||||
.Include(t => t.Group)
|
||||
.Include(t => t.UnitFilters)
|
||||
.ThenInclude(t => t.FieldFilters)
|
||||
.ThenInclude(t => t.Field)
|
||||
.ThenInclude(t => t.UnitField)
|
||||
.Include(t => t.UnitFilters)
|
||||
.ThenInclude(t => t.RelationshipFilters)
|
||||
.FirstOrDefaultAsync(t => t.Id == job.Id);
|
||||
@@ -306,7 +306,7 @@ namespace PARR.API.Controllers.V1
|
||||
.Include(t => t.Group)
|
||||
.Include(t => t.UnitFilters)
|
||||
.ThenInclude(t => t.FieldFilters)
|
||||
.ThenInclude(t => t.Field)
|
||||
.ThenInclude(t => t.UnitField)
|
||||
.Include(t => t.UnitFilters)
|
||||
.ThenInclude(t => t.RelationshipFilters)
|
||||
.FirstAsync(t => t.Id == orig.Id);
|
||||
@@ -450,9 +450,9 @@ namespace PARR.API.Controllers.V1
|
||||
};
|
||||
}
|
||||
|
||||
private static FieldFilter CreateFieldFilter(Guid unitFilterId, Guid fieldId, string valueMask)
|
||||
private static JobFieldFilter CreateFieldFilter(Guid unitFilterId, Guid fieldId, string valueMask)
|
||||
{
|
||||
return new FieldFilter
|
||||
return new JobFieldFilter
|
||||
{
|
||||
UnitFilterId = unitFilterId,
|
||||
DateCreated = DateTimeOffset.UtcNow,
|
||||
|
||||
@@ -110,18 +110,26 @@ namespace PARR.API.MappingProfiles
|
||||
|
||||
CreateMap<UnitFieldValue, UnitFieldValueResponse>();
|
||||
|
||||
CreateMap<UnitInValue, AttributeResponse>()
|
||||
.ForMember(d => d.Field, o => o.MapFrom(s => s.Field))
|
||||
.ForMember(d => d.Value, o => o.MapFrom(s => s.Value));
|
||||
|
||||
CreateMap<Unit, UnitResponse>()
|
||||
.Include<Unit, UnitWithAttributesResponse>()
|
||||
.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.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.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()
|
||||
}
|
||||
)
|
||||
));
|
||||
#endregion
|
||||
|
||||
#region WorkGroup
|
||||
@@ -307,9 +315,9 @@ namespace PARR.API.MappingProfiles
|
||||
CreateMap<JobUnitFilter, UnitFilterResponse>()
|
||||
.ForMember(d => d.UnitFilterMask, o => o.MapFrom(d => d.UnitFilter));
|
||||
|
||||
CreateMap<FieldFilter, FieldResponse>();
|
||||
CreateMap<JobFieldFilter, FieldResponse>();
|
||||
|
||||
CreateMap<FieldFilter, FieldFilterResponse>();
|
||||
CreateMap<JobFieldFilter, FieldFilterResponse>();
|
||||
|
||||
CreateMap<JobRelationshipFilter, RelationshipFilterResponse>()
|
||||
.ForMember(d => d.Field, o => o.MapFrom(s => s.UnitField));
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace PARR.API.MappingProfiles
|
||||
relationshipFilter.UnitFilterId = d.Id;
|
||||
});
|
||||
|
||||
CreateMap<FieldFilterRequest, FieldFilter>()
|
||||
CreateMap<FieldFilterRequest, JobFieldFilter>()
|
||||
.ForMember(d => d.Id, o => o.MapFrom(s => Guid.NewGuid()))
|
||||
.ForMember(d => d.DateCreated, o => o.MapFrom(s => DateTimeOffset.UtcNow));
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ namespace PARR.DAL.Context
|
||||
|
||||
#region Job
|
||||
|
||||
public DbSet<FieldFilter> FieldFilters { get; set; }
|
||||
public DbSet<JobFieldFilter> FieldFilters { get; set; }
|
||||
|
||||
public DbSet<Job> Jobs { get; set; }
|
||||
|
||||
|
||||
3840
PARR.DAL/Migrations/20250922040409_tblUnitFieldsAddIsMultipleValueClmn.Designer.cs
generated
Normal file
3840
PARR.DAL/Migrations/20250922040409_tblUnitFieldsAddIsMultipleValueClmn.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,52 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PARR.DAL.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class tblUnitFieldsAddIsMultipleValueClmn : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_UnitInValues",
|
||||
schema: "unit",
|
||||
table: "UnitInValues");
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsMultipleValue",
|
||||
schema: "unit",
|
||||
table: "Fields",
|
||||
type: "boolean",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_UnitInValues",
|
||||
schema: "unit",
|
||||
table: "UnitInValues",
|
||||
columns: new[] { "UnitId", "FieldId", "ValueId" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropPrimaryKey(
|
||||
name: "PK_UnitInValues",
|
||||
schema: "unit",
|
||||
table: "UnitInValues");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsMultipleValue",
|
||||
schema: "unit",
|
||||
table: "Fields");
|
||||
|
||||
migrationBuilder.AddPrimaryKey(
|
||||
name: "PK_UnitInValues",
|
||||
schema: "unit",
|
||||
table: "UnitInValues",
|
||||
columns: new[] { "UnitId", "FieldId" });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1542,40 +1542,6 @@ namespace PARR.DAL.Migrations
|
||||
b.ToTable("Hosts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Job.FieldFilter", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset?>("DateModified")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid>("FieldId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("UnitFilterId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("ValueMask")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FieldId");
|
||||
|
||||
b.HasIndex("UnitFilterId");
|
||||
|
||||
b.ToTable("FieldFilters", "job", t =>
|
||||
{
|
||||
t.HasComment("Таблица описания критериев выборки аттрибутов ЭК");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Job.Job", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@@ -1631,6 +1597,40 @@ namespace PARR.DAL.Migrations
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Job.JobFieldFilter", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset?>("DateModified")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid>("FieldId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("UnitFilterId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("ValueMask")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FieldId");
|
||||
|
||||
b.HasIndex("UnitFilterId");
|
||||
|
||||
b.ToTable("FieldFilters", "job", t =>
|
||||
{
|
||||
t.HasComment("Таблица описания критериев выборки аттрибутов ЭК");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Job.JobGroup", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@@ -2790,6 +2790,9 @@ namespace PARR.DAL.Migrations
|
||||
b.Property<string>("EsppName")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool?>("IsMultipleValue")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AihitName");
|
||||
@@ -2899,16 +2902,16 @@ namespace PARR.DAL.Migrations
|
||||
b.Property<Guid>("FieldId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("ValueId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset?>("DateModified")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid>("ValueId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("UnitId", "FieldId");
|
||||
b.HasKey("UnitId", "FieldId", "ValueId");
|
||||
|
||||
b.HasIndex("FieldId");
|
||||
|
||||
@@ -3237,25 +3240,6 @@ namespace PARR.DAL.Migrations
|
||||
b.Navigation("WorkGroup");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Job.FieldFilter", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.Unit.UnitField", "Field")
|
||||
.WithMany()
|
||||
.HasForeignKey("FieldId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.Job.JobUnitFilter", "UnitFilter")
|
||||
.WithMany("FieldFilters")
|
||||
.HasForeignKey("UnitFilterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Field");
|
||||
|
||||
b.Navigation("UnitFilter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Job.Job", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.Job.JobGroup", "Group")
|
||||
@@ -3275,6 +3259,25 @@ namespace PARR.DAL.Migrations
|
||||
b.Navigation("Tnk");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Job.JobFieldFilter", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.Unit.UnitField", "UnitField")
|
||||
.WithMany()
|
||||
.HasForeignKey("FieldId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.Job.JobUnitFilter", "UnitFilter")
|
||||
.WithMany("FieldFilters")
|
||||
.HasForeignKey("UnitFilterId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("UnitField");
|
||||
|
||||
b.Navigation("UnitFilter");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Job.JobRelationshipFilter", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.Unit.UnitField", "UnitField")
|
||||
@@ -3486,7 +3489,7 @@ namespace PARR.DAL.Migrations
|
||||
modelBuilder.Entity("PARR.DAL.Models.Unit.UnitFieldInUnitFieldValue", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.Unit.UnitField", "Field")
|
||||
.WithMany("FieldValues")
|
||||
.WithMany("UnitFieldValues")
|
||||
.HasForeignKey("FieldId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@@ -3796,10 +3799,10 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Unit.UnitField", b =>
|
||||
{
|
||||
b.Navigation("FieldValues");
|
||||
|
||||
b.Navigation("RelationshipFilters");
|
||||
|
||||
b.Navigation("UnitFieldValues");
|
||||
|
||||
b.Navigation("UnitInValues");
|
||||
|
||||
b.Navigation("Units");
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace PARR.DAL.Models.Job
|
||||
{
|
||||
[Table("FieldFilters", Schema = DataContextSettings.Job)]
|
||||
[Comment("Таблица описания критериев выборки аттрибутов ЭК")]
|
||||
public class FieldFilter : IBase//TODO Почему этот не Job тра та та
|
||||
public class JobFieldFilter : IBase
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
@@ -26,7 +26,7 @@ namespace PARR.DAL.Models.Job
|
||||
|
||||
|
||||
[ForeignKey(nameof(FieldId))]
|
||||
public UnitField? Field { get; set; }//TODO как-то определитесь уже просто Field или UnitField
|
||||
public UnitField? UnitField { get; set; }
|
||||
|
||||
[ForeignKey(nameof(UnitFilterId))]
|
||||
public JobUnitFilter? UnitFilter { get; set; }
|
||||
@@ -8,7 +8,7 @@ namespace PARR.DAL.Models.Job
|
||||
[Table("RelationshipFilters", Schema = DataContextSettings.Job)]
|
||||
[Comment("Таблица фильтров связей ЭК")]
|
||||
[PrimaryKey(nameof(UnitFilterId), nameof(FieldId))]
|
||||
public class JobRelationshipFilter //: IBase //TODO Почему этот Job тра та та
|
||||
public class JobRelationshipFilter //: IBase
|
||||
{
|
||||
//[Key]
|
||||
//public Guid Id { get; set; }
|
||||
@@ -45,7 +45,7 @@ namespace PARR.DAL.Models.Job
|
||||
|
||||
|
||||
[ForeignKey(nameof(FieldId))]
|
||||
public UnitField? UnitField { get; set; }//TODO как-то определитесь уже просто Field или UnitField
|
||||
public UnitField? UnitField { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace PARR.DAL.Models.Job
|
||||
[ForeignKey(nameof(JobId))]
|
||||
public Job? Job { get; set; }
|
||||
|
||||
public ICollection<FieldFilter> FieldFilters { get; set; } = new HashSet<FieldFilter>();
|
||||
public ICollection<JobFieldFilter> FieldFilters { get; set; } = new HashSet<JobFieldFilter>();
|
||||
|
||||
public ICollection<JobRelationshipFilter> RelationshipFilters { get; set; } = new HashSet<JobRelationshipFilter>();
|
||||
}
|
||||
|
||||
@@ -41,6 +41,10 @@ namespace PARR.DAL.Models.Unit
|
||||
/// </summary>
|
||||
public string? DisplayName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Могут ли принимать несколько значений. Из АИХ ИТ приходят значения разделённые запятой
|
||||
/// </summary>
|
||||
public bool? IsMultipleValue { get; set; }
|
||||
|
||||
|
||||
public ICollection<UnitInField> Units { get; set; } = new HashSet<UnitInField>();
|
||||
@@ -48,7 +52,7 @@ namespace PARR.DAL.Models.Unit
|
||||
public ICollection<UnitInValue> UnitInValues { get; set; } = new HashSet<UnitInValue>();
|
||||
|
||||
|
||||
public ICollection<UnitFieldInUnitFieldValue> FieldValues { get; set; } = new HashSet<UnitFieldInUnitFieldValue>();
|
||||
public ICollection<UnitFieldInUnitFieldValue> UnitFieldValues { get; set; } = new HashSet<UnitFieldInUnitFieldValue>();
|
||||
|
||||
public ICollection<JobRelationshipFilter> RelationshipFilters { get; set; } = new HashSet<JobRelationshipFilter>();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace PARR.DAL.Models.Unit
|
||||
|
||||
[Table("UnitInValues", Schema = DataContextSettings.Unit)]
|
||||
[Comment("Таблица связи ЭК с полями и со значениями")]
|
||||
[PrimaryKey(nameof(UnitId), nameof(FieldId))]
|
||||
[PrimaryKey(nameof(UnitId), nameof(FieldId), nameof(ValueId))]
|
||||
public class UnitInValue : IBaseDateModified, IBaseDateCreated
|
||||
{
|
||||
public Guid UnitId { get; set; }
|
||||
|
||||
@@ -6,11 +6,11 @@ using PARR.DAL.Services.Interfaces.Job;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations.Job
|
||||
{
|
||||
internal class FieldFilterService : BaseService<Models.Job.FieldFilter>, IFieldFilterService
|
||||
internal class FieldFilterService : BaseService<Models.Job.JobFieldFilter>, IFieldFilterService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
|
||||
protected override DbSet<Models.Job.FieldFilter> EntitySet => dataContext.FieldFilters;
|
||||
protected override DbSet<Models.Job.JobFieldFilter> EntitySet => dataContext.FieldFilters;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
public FieldFilterService(DataContext dataContext, ILogger<FieldFilterService> logger) : base(logger)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces.Job
|
||||
{
|
||||
public interface IFieldFilterService : IBaseService<Models.Job.FieldFilter>
|
||||
public interface IFieldFilterService : IBaseService<Models.Job.JobFieldFilter>
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user