forked from ddrilling/AsbCloudServer
Изменение модели + создание новой схемы БД
This commit is contained in:
parent
8c3f21221b
commit
675da0a5d9
@ -1,25 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace AsbCloudApp.Data.Manuals;
|
||||
|
||||
/// <summary>
|
||||
/// Элемент каталога инструкций
|
||||
/// </summary>
|
||||
public class CatalogItemManualDto
|
||||
{
|
||||
/// <summary>
|
||||
/// DTO категории
|
||||
/// </summary>
|
||||
public FileCategoryDto Category { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// DTO инструкций хранящиеся без папки
|
||||
/// </summary>
|
||||
public IEnumerable<ManualDto> ManualsWithoutFolder { get; set; } = Enumerable.Empty<ManualDto>();
|
||||
|
||||
/// <summary>
|
||||
/// DTO папок с инструкциями
|
||||
/// </summary>
|
||||
public IEnumerable<ManualFolderDto> Folders { get; set; } = Enumerable.Empty<ManualFolderDto>();
|
||||
}
|
@ -4,9 +4,9 @@ using System.Linq;
|
||||
namespace AsbCloudApp.Data.Manuals;
|
||||
|
||||
/// <summary>
|
||||
/// DTO папки для хранения инструкций
|
||||
/// Директория для хранения инструкций
|
||||
/// </summary>
|
||||
public class ManualFolderDto : IId
|
||||
public class ManualDirectoryDto : IId
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public int Id { get; set; }
|
||||
@ -17,19 +17,14 @@ public class ManualFolderDto : IId
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Id родительской папки
|
||||
/// Id родительской директории
|
||||
/// </summary>
|
||||
public int? IdParent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id категории
|
||||
/// Вложенные директории
|
||||
/// </summary>
|
||||
public int IdCategory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Вложенные папки
|
||||
/// </summary>
|
||||
public IEnumerable<ManualFolderDto> Children { get; set; } = Enumerable.Empty<ManualFolderDto>();
|
||||
public IEnumerable<ManualDirectoryDto> Children { get; set; } = Enumerable.Empty<ManualDirectoryDto>();
|
||||
|
||||
/// <summary>
|
||||
/// Хранимые инструкции
|
@ -3,7 +3,7 @@ using System;
|
||||
namespace AsbCloudApp.Data.Manuals;
|
||||
|
||||
/// <summary>
|
||||
/// DTO инструкции
|
||||
/// Инструкция
|
||||
/// </summary>
|
||||
public class ManualDto : IId
|
||||
{
|
||||
@ -21,12 +21,17 @@ public class ManualDto : IId
|
||||
public DateTime DateDownload { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id папки
|
||||
/// Id автора
|
||||
/// </summary>
|
||||
public int? IdFolder { get; set; }
|
||||
public int IdAuthor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id директории
|
||||
/// </summary>
|
||||
public int IdDirectory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id категории файла
|
||||
/// </summary>
|
||||
public int? IdCategory { get; set; }
|
||||
public int IdCategory { get; set; }
|
||||
}
|
@ -13,7 +13,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
namespace AsbCloudDb.Migrations
|
||||
{
|
||||
[DbContext(typeof(AsbCloudDbContext))]
|
||||
[Migration("20230810052950_Add_Manuals")]
|
||||
[Migration("20230907070954_Add_Manuals")]
|
||||
partial class Add_Manuals
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@ -21,7 +21,7 @@ namespace AsbCloudDb.Migrations
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.UseCollation("Russian_Russia.1251")
|
||||
.HasAnnotation("ProductVersion", "6.0.20")
|
||||
.HasAnnotation("ProductVersion", "6.0.21")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.HasPostgresExtension(modelBuilder, "adminpack");
|
||||
@ -434,11 +434,6 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int?>("IdType")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("type")
|
||||
.HasComment("0 = Инструкции");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
@ -796,14 +791,7 @@ namespace AsbCloudDb.Migrations
|
||||
new
|
||||
{
|
||||
Id = 30000,
|
||||
IdType = 0,
|
||||
Name = "АСУ ТП"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 30001,
|
||||
IdType = 0,
|
||||
Name = "Технология бурения"
|
||||
Name = "Инструкции"
|
||||
});
|
||||
});
|
||||
|
||||
@ -1097,36 +1085,43 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<DateTime>("DateDownload")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date_download")
|
||||
.HasComment("Дата загрузки файла");
|
||||
.HasComment("Дата загрузки");
|
||||
|
||||
b.Property<int?>("IdCategory")
|
||||
b.Property<int>("IdAuthor")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_author")
|
||||
.HasComment("Id автора");
|
||||
|
||||
b.Property<int>("IdCategory")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_category")
|
||||
.HasComment("Категория");
|
||||
.HasComment("Id категории файла");
|
||||
|
||||
b.Property<int?>("IdFolder")
|
||||
b.Property<int>("IdDirectory")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_folder")
|
||||
.HasComment("Id папки инструкций");
|
||||
.HasColumnName("id_directory")
|
||||
.HasComment("Id директории");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("name")
|
||||
.HasComment("Название файла");
|
||||
.HasComment("Название");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IdAuthor");
|
||||
|
||||
b.HasIndex("IdCategory");
|
||||
|
||||
b.HasIndex("IdFolder");
|
||||
b.HasIndex("IdDirectory");
|
||||
|
||||
b.ToTable("t_manual");
|
||||
|
||||
b.HasComment("Инструкции");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Manuals.ManualFolder", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Manuals.ManualDirectory", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -1135,31 +1130,24 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("IdCategory")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_category")
|
||||
.HasComment("Категория");
|
||||
|
||||
b.Property<int?>("IdParent")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_parent")
|
||||
.HasComment("Родительская папки");
|
||||
.HasComment("Id родительской директории");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("name")
|
||||
.HasComment("Название папки");
|
||||
.HasComment("Название");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IdCategory");
|
||||
|
||||
b.HasIndex("IdParent");
|
||||
|
||||
b.ToTable("t_manual_folder");
|
||||
b.ToTable("t_manual_directory");
|
||||
|
||||
b.HasComment("Папка для инструкций");
|
||||
b.HasComment("Директория для инструкций");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Measure", b =>
|
||||
@ -2269,8 +2257,8 @@ namespace AsbCloudDb.Migrations
|
||||
new
|
||||
{
|
||||
Id = 524,
|
||||
Description = "Разрешить просмотр инструкций",
|
||||
Name = "Manual.view"
|
||||
Description = "Разрешить получение инструкций",
|
||||
Name = "Manual.get"
|
||||
});
|
||||
});
|
||||
|
||||
@ -7802,35 +7790,38 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Manuals.Manual", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.FileCategory", "Category")
|
||||
b.HasOne("AsbCloudDb.Model.User", "Author")
|
||||
.WithMany()
|
||||
.HasForeignKey("IdCategory");
|
||||
.HasForeignKey("IdAuthor")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AsbCloudDb.Model.Manuals.ManualFolder", "Folder")
|
||||
.WithMany("Manuals")
|
||||
.HasForeignKey("IdFolder")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.Navigation("Category");
|
||||
|
||||
b.Navigation("Folder");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Manuals.ManualFolder", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.FileCategory", "Category")
|
||||
.WithMany()
|
||||
.HasForeignKey("IdCategory")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AsbCloudDb.Model.Manuals.ManualFolder", "Parent")
|
||||
b.HasOne("AsbCloudDb.Model.Manuals.ManualDirectory", "Directory")
|
||||
.WithMany("Manuals")
|
||||
.HasForeignKey("IdDirectory")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Author");
|
||||
|
||||
b.Navigation("Category");
|
||||
|
||||
b.Navigation("Directory");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Manuals.ManualDirectory", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.Manuals.ManualDirectory", "Parent")
|
||||
.WithMany("Children")
|
||||
.HasForeignKey("IdParent")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.Navigation("Category");
|
||||
|
||||
b.Navigation("Parent");
|
||||
});
|
||||
|
||||
@ -8459,7 +8450,7 @@ namespace AsbCloudDb.Migrations
|
||||
b.Navigation("FileMarks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Manuals.ManualFolder", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Manuals.ManualDirectory", b =>
|
||||
{
|
||||
b.Navigation("Children");
|
||||
|
@ -10,40 +10,26 @@ namespace AsbCloudDb.Migrations
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "type",
|
||||
table: "t_file_category",
|
||||
type: "integer",
|
||||
nullable: true,
|
||||
comment: "0 = Инструкции");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "t_manual_folder",
|
||||
name: "t_manual_directory",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
name = table.Column<string>(type: "text", nullable: false, comment: "Название папки"),
|
||||
id_parent = table.Column<int>(type: "integer", nullable: true, comment: "Родительская папки"),
|
||||
id_category = table.Column<int>(type: "integer", nullable: false, comment: "Категория")
|
||||
name = table.Column<string>(type: "text", nullable: false, comment: "Название"),
|
||||
id_parent = table.Column<int>(type: "integer", nullable: true, comment: "Id родительской директории")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_t_manual_folder", x => x.id);
|
||||
table.PrimaryKey("PK_t_manual_directory", x => x.id);
|
||||
table.ForeignKey(
|
||||
name: "FK_t_manual_folder_t_file_category_id_category",
|
||||
column: x => x.id_category,
|
||||
principalTable: "t_file_category",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_t_manual_folder_t_manual_folder_id_parent",
|
||||
name: "FK_t_manual_directory_t_manual_directory_id_parent",
|
||||
column: x => x.id_parent,
|
||||
principalTable: "t_manual_folder",
|
||||
principalTable: "t_manual_directory",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
},
|
||||
comment: "Папка для инструкций");
|
||||
comment: "Директория для инструкций");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "t_manual",
|
||||
@ -51,10 +37,11 @@ namespace AsbCloudDb.Migrations
|
||||
{
|
||||
id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
name = table.Column<string>(type: "text", nullable: false, comment: "Название файла"),
|
||||
date_download = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "Дата загрузки файла"),
|
||||
id_category = table.Column<int>(type: "integer", nullable: true, comment: "Категория"),
|
||||
id_folder = table.Column<int>(type: "integer", nullable: true, comment: "Id папки инструкций")
|
||||
name = table.Column<string>(type: "text", nullable: false, comment: "Название"),
|
||||
date_download = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, comment: "Дата загрузки"),
|
||||
id_directory = table.Column<int>(type: "integer", nullable: false, comment: "Id директории"),
|
||||
id_category = table.Column<int>(type: "integer", nullable: false, comment: "Id категории файла"),
|
||||
id_author = table.Column<int>(type: "integer", nullable: false, comment: "Id автора")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
@ -63,11 +50,18 @@ namespace AsbCloudDb.Migrations
|
||||
name: "FK_t_manual_t_file_category_id_category",
|
||||
column: x => x.id_category,
|
||||
principalTable: "t_file_category",
|
||||
principalColumn: "id");
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_t_manual_t_manual_folder_id_folder",
|
||||
column: x => x.id_folder,
|
||||
principalTable: "t_manual_folder",
|
||||
name: "FK_t_manual_t_manual_directory_id_directory",
|
||||
column: x => x.id_directory,
|
||||
principalTable: "t_manual_directory",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_t_manual_t_user_id_author",
|
||||
column: x => x.id_author,
|
||||
principalTable: "t_user",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
},
|
||||
@ -75,12 +69,8 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "t_file_category",
|
||||
columns: new[] { "id", "type", "name", "short_name" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ 30000, 0, "АСУ ТП", null },
|
||||
{ 30001, 0, "Технология бурения", null }
|
||||
});
|
||||
columns: new[] { "id", "name", "short_name" },
|
||||
values: new object[] { 30000, "Инструкции", null });
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "t_permission",
|
||||
@ -88,7 +78,7 @@ namespace AsbCloudDb.Migrations
|
||||
values: new object[,]
|
||||
{
|
||||
{ 523, "Разрешить редактирование инструкций", "Manual.edit" },
|
||||
{ 524, "Разрешить просмотр инструкций", "Manual.view" }
|
||||
{ 524, "Разрешить получение инструкций", "Manual.get" }
|
||||
});
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
@ -100,24 +90,24 @@ namespace AsbCloudDb.Migrations
|
||||
{ 524, 1 }
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_manual_id_author",
|
||||
table: "t_manual",
|
||||
column: "id_author");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_manual_id_category",
|
||||
table: "t_manual",
|
||||
column: "id_category");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_manual_id_folder",
|
||||
name: "IX_t_manual_id_directory",
|
||||
table: "t_manual",
|
||||
column: "id_folder");
|
||||
column: "id_directory");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_manual_folder_id_category",
|
||||
table: "t_manual_folder",
|
||||
column: "id_category");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_t_manual_folder_id_parent",
|
||||
table: "t_manual_folder",
|
||||
name: "IX_t_manual_directory_id_parent",
|
||||
table: "t_manual_directory",
|
||||
column: "id_parent");
|
||||
}
|
||||
|
||||
@ -127,18 +117,13 @@ namespace AsbCloudDb.Migrations
|
||||
name: "t_manual");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "t_manual_folder");
|
||||
name: "t_manual_directory");
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 30000);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_file_category",
|
||||
keyColumn: "id",
|
||||
keyValue: 30001);
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "t_relation_user_role_permission",
|
||||
keyColumns: new[] { "id_permission", "id_user_role" },
|
||||
@ -158,10 +143,6 @@ namespace AsbCloudDb.Migrations
|
||||
table: "t_permission",
|
||||
keyColumn: "id",
|
||||
keyValue: 524);
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "type",
|
||||
table: "t_file_category");
|
||||
}
|
||||
}
|
||||
}
|
@ -432,11 +432,6 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int?>("IdType")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("type")
|
||||
.HasComment("0 = Инструкции");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
@ -794,14 +789,7 @@ namespace AsbCloudDb.Migrations
|
||||
new
|
||||
{
|
||||
Id = 30000,
|
||||
IdType = 0,
|
||||
Name = "АСУ ТП"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = 30001,
|
||||
IdType = 0,
|
||||
Name = "Технология бурения"
|
||||
Name = "Инструкции"
|
||||
});
|
||||
});
|
||||
|
||||
@ -1095,36 +1083,43 @@ namespace AsbCloudDb.Migrations
|
||||
b.Property<DateTime>("DateDownload")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("date_download")
|
||||
.HasComment("Дата загрузки файла");
|
||||
.HasComment("Дата загрузки");
|
||||
|
||||
b.Property<int?>("IdCategory")
|
||||
b.Property<int>("IdAuthor")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_author")
|
||||
.HasComment("Id автора");
|
||||
|
||||
b.Property<int>("IdCategory")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_category")
|
||||
.HasComment("Категория");
|
||||
.HasComment("Id категории файла");
|
||||
|
||||
b.Property<int?>("IdFolder")
|
||||
b.Property<int>("IdDirectory")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_folder")
|
||||
.HasComment("Id папки инструкций");
|
||||
.HasColumnName("id_directory")
|
||||
.HasComment("Id директории");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("name")
|
||||
.HasComment("Название файла");
|
||||
.HasComment("Название");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IdAuthor");
|
||||
|
||||
b.HasIndex("IdCategory");
|
||||
|
||||
b.HasIndex("IdFolder");
|
||||
b.HasIndex("IdDirectory");
|
||||
|
||||
b.ToTable("t_manual");
|
||||
|
||||
b.HasComment("Инструкции");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Manuals.ManualFolder", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Manuals.ManualDirectory", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
@ -1133,31 +1128,24 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("IdCategory")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_category")
|
||||
.HasComment("Категория");
|
||||
|
||||
b.Property<int?>("IdParent")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id_parent")
|
||||
.HasComment("Родительская папки");
|
||||
.HasComment("Id родительской директории");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text")
|
||||
.HasColumnName("name")
|
||||
.HasComment("Название папки");
|
||||
.HasComment("Название");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("IdCategory");
|
||||
|
||||
b.HasIndex("IdParent");
|
||||
|
||||
b.ToTable("t_manual_folder");
|
||||
b.ToTable("t_manual_directory");
|
||||
|
||||
b.HasComment("Папка для инструкций");
|
||||
b.HasComment("Директория для инструкций");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Measure", b =>
|
||||
@ -2267,8 +2255,8 @@ namespace AsbCloudDb.Migrations
|
||||
new
|
||||
{
|
||||
Id = 524,
|
||||
Description = "Разрешить просмотр инструкций",
|
||||
Name = "Manual.view"
|
||||
Description = "Разрешить получение инструкций",
|
||||
Name = "Manual.get"
|
||||
});
|
||||
});
|
||||
|
||||
@ -7800,35 +7788,38 @@ namespace AsbCloudDb.Migrations
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Manuals.Manual", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.FileCategory", "Category")
|
||||
b.HasOne("AsbCloudDb.Model.User", "Author")
|
||||
.WithMany()
|
||||
.HasForeignKey("IdCategory");
|
||||
.HasForeignKey("IdAuthor")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AsbCloudDb.Model.Manuals.ManualFolder", "Folder")
|
||||
.WithMany("Manuals")
|
||||
.HasForeignKey("IdFolder")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.Navigation("Category");
|
||||
|
||||
b.Navigation("Folder");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Manuals.ManualFolder", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.FileCategory", "Category")
|
||||
.WithMany()
|
||||
.HasForeignKey("IdCategory")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AsbCloudDb.Model.Manuals.ManualFolder", "Parent")
|
||||
b.HasOne("AsbCloudDb.Model.Manuals.ManualDirectory", "Directory")
|
||||
.WithMany("Manuals")
|
||||
.HasForeignKey("IdDirectory")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Author");
|
||||
|
||||
b.Navigation("Category");
|
||||
|
||||
b.Navigation("Directory");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Manuals.ManualDirectory", b =>
|
||||
{
|
||||
b.HasOne("AsbCloudDb.Model.Manuals.ManualDirectory", "Parent")
|
||||
.WithMany("Children")
|
||||
.HasForeignKey("IdParent")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.Navigation("Category");
|
||||
|
||||
b.Navigation("Parent");
|
||||
});
|
||||
|
||||
@ -8457,7 +8448,7 @@ namespace AsbCloudDb.Migrations
|
||||
b.Navigation("FileMarks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Manuals.ManualFolder", b =>
|
||||
modelBuilder.Entity("AsbCloudDb.Model.Manuals.ManualDirectory", b =>
|
||||
{
|
||||
b.Navigation("Children");
|
||||
|
||||
|
@ -79,7 +79,7 @@ namespace AsbCloudDb.Model
|
||||
public DbSet<Notification> Notifications => Set<Notification>();
|
||||
public DbSet<NotificationCategory> NotificationCategories => Set<NotificationCategory>();
|
||||
public DbSet<Manual> Manuals => Set<Manual>();
|
||||
public DbSet<ManualFolder> ManualFolders => Set<ManualFolder>();
|
||||
public DbSet<ManualDirectory> ManualDirectories => Set<ManualDirectory>();
|
||||
|
||||
|
||||
public AsbCloudDbContext() : base()
|
||||
@ -392,16 +392,16 @@ namespace AsbCloudDb.Model
|
||||
entity.HasKey(x => new { x.IdWell, x.IdUser });
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ManualFolder>()
|
||||
modelBuilder.Entity<ManualDirectory>()
|
||||
.HasOne(mf => mf.Parent)
|
||||
.WithMany(mf => mf.Children)
|
||||
.HasForeignKey(mf => mf.IdParent)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
modelBuilder.Entity<Manual>()
|
||||
.HasOne(m => m.Folder)
|
||||
.HasOne(m => m.Directory)
|
||||
.WithMany(f => f.Manuals)
|
||||
.HasForeignKey(m => m.IdFolder)
|
||||
.HasForeignKey(m => m.IdDirectory)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
DefaultData.DefaultContextData.Fill(modelBuilder);
|
||||
|
@ -75,8 +75,7 @@
|
||||
|
||||
new () {Id = 20000, Name = "Справки по страницам"},
|
||||
|
||||
new() { Id = 30000, Name = "АСУ ТП", IdType = FileCategory.IdFileCategoryTypeManuals},
|
||||
new() { Id = 30001, Name = "Технология бурения", IdType = FileCategory.IdFileCategoryTypeManuals}
|
||||
new() { Id = 30000, Name = "Инструкции"},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +158,7 @@
|
||||
new() { Id = 522, Name = "UserSettings.delete", Description = "Разрешить удаление всех настроек пользователя"},
|
||||
|
||||
new() { Id = 523, Name = "Manual.edit", Description = "Разрешить редактирование инструкций" },
|
||||
new() { Id = 524, Name = "Manual.view", Description = "Разрешить просмотр инструкций"}
|
||||
new() { Id = 524, Name = "Manual.get", Description = "Разрешить получение инструкций"}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,6 @@ namespace AsbCloudDb.Model
|
||||
[Table("t_file_category"), Comment("Категории файлов")]
|
||||
public class FileCategory : IId
|
||||
{
|
||||
public const int IdFileCategoryTypeManuals = 0;
|
||||
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int Id { get; set; }
|
||||
@ -18,8 +16,5 @@ namespace AsbCloudDb.Model
|
||||
|
||||
[Column("short_name"), Comment("Короткое название категории")]
|
||||
public string? ShortName { get; set; }
|
||||
|
||||
[Column("type"), Comment("0 = Инструкции")]
|
||||
public int? IdType { get; set; }
|
||||
}
|
||||
}
|
@ -72,7 +72,7 @@ namespace AsbCloudDb.Model
|
||||
DbSet<Notification> Notifications { get; }
|
||||
DbSet<NotificationCategory> NotificationCategories { get; }
|
||||
DbSet<Manual> Manuals { get; }
|
||||
DbSet<ManualFolder> ManualFolders { get; }
|
||||
DbSet<ManualDirectory> ManualDirectories { get; }
|
||||
DatabaseFacade Database { get; }
|
||||
|
||||
Task<int> RefreshMaterializedViewAsync(string mwName, CancellationToken token);
|
||||
|
@ -12,21 +12,27 @@ public class Manual : IId
|
||||
[Column("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("name"), Comment("Название файла")]
|
||||
[Column("name"), Comment("Название")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Column("date_download"), Comment("Дата загрузки файла")]
|
||||
[Column("date_download"), Comment("Дата загрузки")]
|
||||
public DateTime DateDownload { get; set; }
|
||||
|
||||
[Column("id_category"), Comment("Категория")]
|
||||
public int? IdCategory { get; set; }
|
||||
[Column("id_directory"), Comment("Id директории")]
|
||||
public int IdDirectory { get; set; }
|
||||
|
||||
[Column("id_category"), Comment("Id категории файла")]
|
||||
public int IdCategory { get; set; }
|
||||
|
||||
[Column("id_author"), Comment("Id автора")]
|
||||
public int IdAuthor { get; set; }
|
||||
|
||||
[ForeignKey(nameof(IdDirectory))]
|
||||
public virtual ManualDirectory Directory { get; set; } = null!;
|
||||
|
||||
[ForeignKey(nameof(IdCategory))]
|
||||
public virtual FileCategory? Category { get; set; }
|
||||
public virtual FileCategory Category { get; set; } = null!;
|
||||
|
||||
[Column("id_folder"), Comment("Id папки инструкций")]
|
||||
public int? IdFolder { get; set; }
|
||||
|
||||
[ForeignKey(nameof(IdFolder))]
|
||||
public virtual ManualFolder? Folder { get; set; }
|
||||
[ForeignKey(nameof(IdAuthor))]
|
||||
public virtual User Author { get; set; } = null!;
|
||||
}
|
27
AsbCloudDb/Model/Manuals/ManualDirectory.cs
Normal file
27
AsbCloudDb/Model/Manuals/ManualDirectory.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace AsbCloudDb.Model.Manuals;
|
||||
|
||||
[Table("t_manual_directory"), Comment("Директория для инструкций")]
|
||||
public class ManualDirectory : IId
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("name"), Comment("Название")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Column("id_parent"), Comment("Id родительской директории")]
|
||||
public int? IdParent { get; set; }
|
||||
|
||||
[ForeignKey(nameof(IdParent))]
|
||||
public virtual ManualDirectory? Parent { get; set; }
|
||||
|
||||
public virtual ICollection<ManualDirectory>? Children { get; set; }
|
||||
|
||||
public virtual ICollection<Manual>? Manuals { get; set; }
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace AsbCloudDb.Model.Manuals;
|
||||
|
||||
[Table("t_manual_folder"), Comment("Папка для инструкций")]
|
||||
public class ManualFolder : IId
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column("name"), Comment("Название папки")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[Column("id_parent"), Comment("Родительская папки")]
|
||||
public int? IdParent { get; set; }
|
||||
|
||||
[ForeignKey(nameof(IdParent))]
|
||||
public virtual ManualFolder? Parent { get; set; }
|
||||
|
||||
[Column("id_category"), Comment("Категория")]
|
||||
public int IdCategory { get; set; }
|
||||
|
||||
[ForeignKey(nameof(IdCategory))]
|
||||
public virtual FileCategory Category { get; set; } = null!;
|
||||
|
||||
public virtual ICollection<ManualFolder>? Children { get; set; }
|
||||
|
||||
public virtual ICollection<Manual>? Manuals { get; set; }
|
||||
}
|
Loading…
Reference in New Issue
Block a user