feat(api,dal): удалена старая таблица Works. Переделаны запросы в API из в Works в Jobs

This commit is contained in:
Mikhail Trubnikov
2025-12-09 16:00:38 +10:00
parent 362da02233
commit b033f95116
22 changed files with 4035 additions and 473 deletions

View File

@@ -31,7 +31,6 @@ namespace PARR.DAL.Context
public DbSet<Process> Processes { get; set; }
public DbSet<Subprocess> Subprocesses { get; set; }
public DbSet<Tnk> Tnks { get; set; }
public DbSet<Work> Works { get; set; }
public DbSet<ApplicationsInWork> ApplicationsInWorks { get; set; }

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,69 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class removeWorks : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ApplicationsInWorks_Works_WorkId",
table: "ApplicationsInWorks");
migrationBuilder.DropTable(
name: "Works");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Works",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
TnkId = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
EsppId = table.Column<int>(type: "integer", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
TemplateNameMask = table.Column<string>(type: "text", nullable: false),
TemplateSuffix = table.Column<string>(type: "text", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Works", x => x.Id);
table.ForeignKey(
name: "FK_Works_Tnks_TnkId",
column: x => x.TnkId,
principalTable: "Tnks",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Works_EsppId",
table: "Works",
column: "EsppId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Works_TnkId",
table: "Works",
column: "TnkId");
migrationBuilder.AddForeignKey(
name: "FK_ApplicationsInWorks_Works_WorkId",
table: "ApplicationsInWorks",
column: "WorkId",
principalTable: "Works",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@@ -3065,45 +3065,6 @@ namespace PARR.DAL.Migrations
b.ToTable("WeekendDays");
});
modelBuilder.Entity("PARR.DAL.Models.Work", 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<int>("EsppId")
.HasColumnType("integer");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TemplateNameMask")
.IsRequired()
.HasColumnType("text");
b.Property<string>("TemplateSuffix")
.HasColumnType("text");
b.Property<Guid>("TnkId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("EsppId")
.IsUnique();
b.HasIndex("TnkId");
b.ToTable("Works");
});
modelBuilder.Entity("PARR.DAL.Models.WorkGroup", b =>
{
b.Property<Guid>("Id")
@@ -3209,15 +3170,7 @@ namespace PARR.DAL.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.Work", "Work")
.WithMany("ApplicationsInWorks")
.HasForeignKey("WorkId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Application");
b.Navigation("Work");
});
modelBuilder.Entity("PARR.DAL.Models.DistributionPeriod", b =>
@@ -3328,7 +3281,7 @@ namespace PARR.DAL.Migrations
.IsRequired();
b.HasOne("PARR.DAL.Models.Tnk", "Tnk")
.WithMany()
.WithMany("Jobs")
.HasForeignKey("TnkId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
@@ -3676,17 +3629,6 @@ namespace PARR.DAL.Migrations
b.Navigation("User");
});
modelBuilder.Entity("PARR.DAL.Models.Work", b =>
{
b.HasOne("PARR.DAL.Models.Tnk", "Tnk")
.WithMany("Works")
.HasForeignKey("TnkId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Tnk");
});
modelBuilder.Entity("PARR.DAL.Models.WorkGroup", b =>
{
b.HasOne("PARR.DAL.Models.ResponseArea", "ResponseArea")
@@ -3871,7 +3813,7 @@ namespace PARR.DAL.Migrations
modelBuilder.Entity("PARR.DAL.Models.Tnk", b =>
{
b.Navigation("Works");
b.Navigation("Jobs");
});
modelBuilder.Entity("PARR.DAL.Models.Unit.Unit", b =>
@@ -3912,11 +3854,6 @@ namespace PARR.DAL.Migrations
b.Navigation("Roles");
});
modelBuilder.Entity("PARR.DAL.Models.Work", b =>
{
b.Navigation("ApplicationsInWorks");
});
modelBuilder.Entity("PARR.DAL.Models.WorkGroup", b =>
{
b.Navigation("AppInWorks");

View File

@@ -105,8 +105,8 @@ namespace PARR.DAL.Models
/// </summary>
public string? AgentScript { get; set; }
[ForeignKey(nameof(WorkId))]
public Work? Work { get; set; }
//[ForeignKey(nameof(WorkId))]
//public Work? Work { get; set; }
[ForeignKey(nameof(ApplicationId))]
public Application? Application { get; set; }

View File

@@ -29,6 +29,7 @@ namespace PARR.DAL.Models
[ForeignKey(nameof(SubprocessId))]
public Subprocess? Subprocess { get; set; }
public ICollection<Work> Works { get; set; } = new HashSet<Work>();
public ICollection<Job.Job> Jobs { get; set; } = new HashSet<Job.Job>();
}
}

View File

@@ -1,40 +0,0 @@
using Microsoft.EntityFrameworkCore;
using PARR.DAL.Models.Base;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PARR.DAL.Models
{
[Table("Works")]
[Index(nameof(EsppId), IsUnique = true)]
public class Work : IBase
{
[Key]
public Guid Id { get; set; }
public DateTimeOffset DateCreated { get; set; }
public DateTimeOffset? DateModified { get; set; }
public required string Name { get; set; }
/// <summary>
/// Маска для динамического формирования имени шаблона
/// </summary>
public required string TemplateNameMask { get; set; }
/// <summary>
/// Короткое имя, для формирования имени шаблона
/// </summary>
public string? TemplateSuffix { get; set; }
public int EsppId { get; set; }
public Guid TnkId { get; set; }
[ForeignKey(nameof(TnkId))]
public Tnk? Tnk { get; set; }
public ICollection<ApplicationsInWork> ApplicationsInWorks { get; set; } = new HashSet<ApplicationsInWork>();
}
}

View File

@@ -65,7 +65,6 @@ namespace PARR.DAL
services.AddTransient<IApplicationTypeService, ApplicationTypeService>();
services.AddTransient<IApplicationInHostService, ApplicationInHostService>();
services.AddTransient<IApplicationsInWorkService, ApplicationsInWorkService>();
services.AddTransient<IWorkService, WorkService>();
services.AddTransient<IApplicationService, ApplicationService>();
services.AddTransient<IProcessService, ProcessService>();
services.AddTransient<ISubprocessService, SubprocessService>();

View File

@@ -1,25 +0,0 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using PARR.DAL.Context;
using PARR.DAL.Models;
using PARR.DAL.Services.Abstracts;
using PARR.DAL.Services.Interfaces;
namespace PARR.DAL.Services.Implementations
{
internal class WorkService : BaseService<Work>, IWorkService
{
private readonly DataContext dataContext;
private readonly ILogger<WorkService> logger;
public WorkService(DataContext dataContext, ILogger<WorkService> logger) : base(logger)
{
this.dataContext = dataContext;
this.logger = logger;
}
protected override DbSet<Work> EntitySet => dataContext.Works;
protected override DataContext EntitiContext => dataContext;
}
}

View File

@@ -1,9 +0,0 @@
using PARR.DAL.Models;
using PARR.DAL.Services.Interfaces.Base;
namespace PARR.DAL.Services.Interfaces
{
public interface IWorkService : IBaseService<Work>
{
}
}