feat(dal): Добавлена таблица WorkGroups и AppInWorkGroups
This commit is contained in:
@@ -10,6 +10,8 @@ namespace PARR.DAL.Context
|
||||
public DataContext(DbContextOptions<DataContext> options) : base(options) { }
|
||||
|
||||
public DbSet<Host> Hosts { get; set; }
|
||||
public DbSet<WorkGroup> WorkGroups { get; set; }
|
||||
public DbSet<AppInWorkInWorkGroup> AppInWorkInWorkGroups { get; set; }
|
||||
public DbSet<EkStatus> EkStatuses { get; set; }
|
||||
public DbSet<ResponseArea> ResponseAreas { get; set; }
|
||||
public DbSet<Application> Applications { get; set; }
|
||||
|
||||
2728
PARR.DAL/Migrations/20240603051427_TblAddWorkGroup.Designer.cs
generated
Normal file
2728
PARR.DAL/Migrations/20240603051427_TblAddWorkGroup.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
97
PARR.DAL/Migrations/20240603051427_TblAddWorkGroup.cs
Normal file
97
PARR.DAL/Migrations/20240603051427_TblAddWorkGroup.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PARR.DAL.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class TblAddWorkGroup : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "WorkGroupId",
|
||||
table: "Hosts",
|
||||
type: "uuid",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "WorkGroups",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
Name = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_WorkGroups", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AppInWorkInWorkGroups",
|
||||
columns: table => new
|
||||
{
|
||||
ApplicationsInWorkId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
WorkGroupId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AppInWorkInWorkGroups", x => new { x.ApplicationsInWorkId, x.WorkGroupId });
|
||||
table.ForeignKey(
|
||||
name: "FK_AppInWorkInWorkGroups_ApplicationsInWorks_ApplicationsInWor~",
|
||||
column: x => x.ApplicationsInWorkId,
|
||||
principalTable: "ApplicationsInWorks",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_AppInWorkInWorkGroups_WorkGroups_WorkGroupId",
|
||||
column: x => x.WorkGroupId,
|
||||
principalTable: "WorkGroups",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Hosts_WorkGroupId",
|
||||
table: "Hosts",
|
||||
column: "WorkGroupId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AppInWorkInWorkGroups_WorkGroupId",
|
||||
table: "AppInWorkInWorkGroups",
|
||||
column: "WorkGroupId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Hosts_WorkGroups_WorkGroupId",
|
||||
table: "Hosts",
|
||||
column: "WorkGroupId",
|
||||
principalTable: "WorkGroups",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Hosts_WorkGroups_WorkGroupId",
|
||||
table: "Hosts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "AppInWorkInWorkGroups");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "WorkGroups");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Hosts_WorkGroupId",
|
||||
table: "Hosts");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "WorkGroupId",
|
||||
table: "Hosts");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -89,6 +89,21 @@ namespace PARR.DAL.Migrations
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.AppInWorkInWorkGroup", b =>
|
||||
{
|
||||
b.Property<Guid>("ApplicationsInWorkId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("WorkGroupId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("ApplicationsInWorkId", "WorkGroupId");
|
||||
|
||||
b.HasIndex("WorkGroupId");
|
||||
|
||||
b.ToTable("AppInWorkInWorkGroups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Application", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@@ -1402,12 +1417,17 @@ namespace PARR.DAL.Migrations
|
||||
b.Property<string>("WorkGroup")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid?>("WorkGroupId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("EkStatusCode");
|
||||
|
||||
b.HasIndex("ResponseAreaCode");
|
||||
|
||||
b.HasIndex("WorkGroupId");
|
||||
|
||||
b.HasIndex("Ek", "IP");
|
||||
|
||||
b.ToTable("Hosts");
|
||||
@@ -2201,6 +2221,24 @@ namespace PARR.DAL.Migrations
|
||||
b.ToTable("Works");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.WorkGroup", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("WorkGroups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.AgentHistory", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.AgentHistoryLevel", "AgentHistoryLevel")
|
||||
@@ -2226,6 +2264,25 @@ namespace PARR.DAL.Migrations
|
||||
b.Navigation("Template");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.AppInWorkInWorkGroup", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.ApplicationsInWork", "ApplicationsInWork")
|
||||
.WithMany("WorkGroups")
|
||||
.HasForeignKey("ApplicationsInWorkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.WorkGroup", "WorkGroup")
|
||||
.WithMany("AppInWorks")
|
||||
.HasForeignKey("WorkGroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ApplicationsInWork");
|
||||
|
||||
b.Navigation("WorkGroup");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Application", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.ApplicationType", "ApplicationType")
|
||||
@@ -2346,9 +2403,15 @@ namespace PARR.DAL.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.WorkGroup", "WorkGroupItem")
|
||||
.WithMany("Hosts")
|
||||
.HasForeignKey("WorkGroupId");
|
||||
|
||||
b.Navigation("EkStatus");
|
||||
|
||||
b.Navigation("ResponseArea");
|
||||
|
||||
b.Navigation("WorkGroupItem");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Order", b =>
|
||||
@@ -2529,6 +2592,8 @@ namespace PARR.DAL.Migrations
|
||||
b.Navigation("EsppSchValues");
|
||||
|
||||
b.Navigation("Templates");
|
||||
|
||||
b.Navigation("WorkGroups");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.EkStatus", b =>
|
||||
@@ -2647,6 +2712,13 @@ namespace PARR.DAL.Migrations
|
||||
{
|
||||
b.Navigation("ApplicationsInWorks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.WorkGroup", b =>
|
||||
{
|
||||
b.Navigation("AppInWorks");
|
||||
|
||||
b.Navigation("Hosts");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
||||
17
PARR.DAL/Models/AppInWorkInWorkGroup.cs
Normal file
17
PARR.DAL/Models/AppInWorkInWorkGroup.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models
|
||||
{
|
||||
[Table("AppInWorkInWorkGroups")]
|
||||
[PrimaryKey(nameof(ApplicationsInWorkId), nameof(WorkGroupId))]
|
||||
public class AppInWorkInWorkGroup
|
||||
{
|
||||
public Guid ApplicationsInWorkId { get; set; }
|
||||
public Guid WorkGroupId { get; set; }
|
||||
|
||||
public ApplicationsInWork? ApplicationsInWork { get; set; }
|
||||
public WorkGroup? WorkGroup { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -108,5 +108,7 @@ namespace PARR.DAL.Models
|
||||
public ICollection<Template> Templates { get; set; } = new HashSet<Template>();
|
||||
|
||||
public ICollection<EsppSchValue> EsppSchValues { get; set; } = new HashSet<EsppSchValue>();
|
||||
|
||||
public ICollection<AppInWorkInWorkGroup> WorkGroups { get; set; } = new HashSet<AppInWorkInWorkGroup>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,8 @@ namespace PARR.DAL.Models
|
||||
|
||||
public string? WorkGroup { get; set; }
|
||||
|
||||
public Guid? WorkGroupId { get; set; }
|
||||
|
||||
//TODO: удалить поле ResponseAreaStr
|
||||
//public string? ResponseAreaStr { get; set; }
|
||||
|
||||
@@ -48,5 +50,8 @@ namespace PARR.DAL.Models
|
||||
|
||||
[ForeignKey(nameof(ResponseAreaCode))]
|
||||
public ResponseArea? ResponseArea { get; set; }
|
||||
|
||||
[ForeignKey(nameof(WorkGroupId))]
|
||||
public WorkGroup? WorkGroupItem { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
23
PARR.DAL/Models/WorkGroup.cs
Normal file
23
PARR.DAL/Models/WorkGroup.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using PARR.DAL.Models.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models
|
||||
{
|
||||
[Table("WorkGroups")]
|
||||
public class WorkGroup : IBase
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
public required string Name { get; set; }
|
||||
|
||||
public ICollection<Host> Hosts { get; set; } = new HashSet<Host>();
|
||||
|
||||
public ICollection<AppInWorkInWorkGroup> AppInWorks { get; set; } = new HashSet<AppInWorkInWorkGroup>();
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,7 @@ namespace PARR.DAL
|
||||
|
||||
// Entity services
|
||||
services.AddTransient<IHostService, HostService>();
|
||||
services.AddTransient<IWorkGroupService, WorkGroupService>();
|
||||
services.AddTransient<IApplicationService, ApplicationService>();
|
||||
services.AddTransient<IApplicationTypeService, ApplicationTypeService>();
|
||||
services.AddTransient<IApplicationInHostService, ApplicationInHostService>();
|
||||
|
||||
28
PARR.DAL/Services/Implementations/WorkGroupService.cs
Normal file
28
PARR.DAL/Services/Implementations/WorkGroupService.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
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 WorkGroupService : BaseService<WorkGroup>, IWorkGroupService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<WorkGroupService> logger;
|
||||
|
||||
protected override DbSet<WorkGroup> EntitySet => dataContext.WorkGroups;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
public WorkGroupService(DataContext dataContext, ILogger<WorkGroupService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
this.logger = logger;
|
||||
}
|
||||
public async Task<WorkGroup?> GetByNameAsync(string name)
|
||||
{
|
||||
return await Get().FirstOrDefaultAsync(t => t.Name == name);
|
||||
}
|
||||
}
|
||||
}
|
||||
10
PARR.DAL/Services/Interfaces/IWorkGroupService.cs
Normal file
10
PARR.DAL/Services/Interfaces/IWorkGroupService.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface IWorkGroupService : IBaseService<WorkGroup>
|
||||
{
|
||||
Task<WorkGroup?> GetByNameAsync(string name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user