diff --git a/AsbCloudApp/Data/Manuals/CatalogItemManualDto.cs b/AsbCloudApp/Data/Manuals/CatalogItemManualDto.cs
deleted file mode 100644
index d4a766d1..00000000
--- a/AsbCloudApp/Data/Manuals/CatalogItemManualDto.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-
-namespace AsbCloudApp.Data.Manuals;
-
-///
-/// Элемент каталога инструкций
-///
-public class CatalogItemManualDto
-{
- ///
- /// DTO категории
- ///
- public FileCategoryDto Category { get; set; } = null!;
-
- ///
- /// DTO инструкций хранящиеся без папки
- ///
- public IEnumerable ManualsWithoutFolder { get; set; } = Enumerable.Empty();
-
- ///
- /// DTO папок с инструкциями
- ///
- public IEnumerable Folders { get; set; } = Enumerable.Empty();
-}
\ No newline at end of file
diff --git a/AsbCloudApp/Data/Manuals/ManualFolderDto.cs b/AsbCloudApp/Data/Manuals/ManualDirectoryDto.cs
similarity index 58%
rename from AsbCloudApp/Data/Manuals/ManualFolderDto.cs
rename to AsbCloudApp/Data/Manuals/ManualDirectoryDto.cs
index 8eef923d..e0513cf9 100644
--- a/AsbCloudApp/Data/Manuals/ManualFolderDto.cs
+++ b/AsbCloudApp/Data/Manuals/ManualDirectoryDto.cs
@@ -4,9 +4,9 @@ using System.Linq;
namespace AsbCloudApp.Data.Manuals;
///
-/// DTO папки для хранения инструкций
+/// Директория для хранения инструкций
///
-public class ManualFolderDto : IId
+public class ManualDirectoryDto : IId
{
///
public int Id { get; set; }
@@ -17,19 +17,14 @@ public class ManualFolderDto : IId
public string Name { get; set; } = null!;
///
- /// Id родительской папки
+ /// Id родительской директории
///
public int? IdParent { get; set; }
-
- ///
- /// Id категории
- ///
- public int IdCategory { get; set; }
///
- /// Вложенные папки
+ /// Вложенные директории
///
- public IEnumerable Children { get; set; } = Enumerable.Empty();
+ public IEnumerable Children { get; set; } = Enumerable.Empty();
///
/// Хранимые инструкции
diff --git a/AsbCloudApp/Data/Manuals/ManualDto.cs b/AsbCloudApp/Data/Manuals/ManualDto.cs
index 8c01f66c..bb89dfbe 100644
--- a/AsbCloudApp/Data/Manuals/ManualDto.cs
+++ b/AsbCloudApp/Data/Manuals/ManualDto.cs
@@ -3,7 +3,7 @@ using System;
namespace AsbCloudApp.Data.Manuals;
///
-/// DTO инструкции
+/// Инструкция
///
public class ManualDto : IId
{
@@ -21,12 +21,17 @@ public class ManualDto : IId
public DateTime DateDownload { get; set; }
///
- /// Id папки
+ /// Id автора
///
- public int? IdFolder { get; set; }
+ public int IdAuthor { get; set; }
+
+ ///
+ /// Id директории
+ ///
+ public int IdDirectory { get; set; }
///
/// Id категории файла
///
- public int? IdCategory { get; set; }
+ public int IdCategory { get; set; }
}
\ No newline at end of file
diff --git a/AsbCloudDb/Migrations/20230810052950_Add_Manuals.Designer.cs b/AsbCloudDb/Migrations/20230907070954_Add_Manuals.Designer.cs
similarity index 99%
rename from AsbCloudDb/Migrations/20230810052950_Add_Manuals.Designer.cs
rename to AsbCloudDb/Migrations/20230907070954_Add_Manuals.Designer.cs
index 578d4680..4aed03e1 100644
--- a/AsbCloudDb/Migrations/20230810052950_Add_Manuals.Designer.cs
+++ b/AsbCloudDb/Migrations/20230907070954_Add_Manuals.Designer.cs
@@ -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("Id"));
- b.Property("IdType")
- .HasColumnType("integer")
- .HasColumnName("type")
- .HasComment("0 = Инструкции");
-
b.Property("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("DateDownload")
.HasColumnType("timestamp with time zone")
.HasColumnName("date_download")
- .HasComment("Дата загрузки файла");
+ .HasComment("Дата загрузки");
- b.Property("IdCategory")
+ b.Property("IdAuthor")
+ .HasColumnType("integer")
+ .HasColumnName("id_author")
+ .HasComment("Id автора");
+
+ b.Property("IdCategory")
.HasColumnType("integer")
.HasColumnName("id_category")
- .HasComment("Категория");
+ .HasComment("Id категории файла");
- b.Property("IdFolder")
+ b.Property("IdDirectory")
.HasColumnType("integer")
- .HasColumnName("id_folder")
- .HasComment("Id папки инструкций");
+ .HasColumnName("id_directory")
+ .HasComment("Id директории");
b.Property("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("Id")
.ValueGeneratedOnAdd()
@@ -1135,31 +1130,24 @@ namespace AsbCloudDb.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
- b.Property("IdCategory")
- .HasColumnType("integer")
- .HasColumnName("id_category")
- .HasComment("Категория");
-
b.Property("IdParent")
.HasColumnType("integer")
.HasColumnName("id_parent")
- .HasComment("Родительская папки");
+ .HasComment("Id родительской директории");
b.Property("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");
diff --git a/AsbCloudDb/Migrations/20230810052950_Add_Manuals.cs b/AsbCloudDb/Migrations/20230907070954_Add_Manuals.cs
similarity index 64%
rename from AsbCloudDb/Migrations/20230810052950_Add_Manuals.cs
rename to AsbCloudDb/Migrations/20230907070954_Add_Manuals.cs
index 0b384ab6..4ee906e3 100644
--- a/AsbCloudDb/Migrations/20230810052950_Add_Manuals.cs
+++ b/AsbCloudDb/Migrations/20230907070954_Add_Manuals.cs
@@ -10,40 +10,26 @@ namespace AsbCloudDb.Migrations
{
protected override void Up(MigrationBuilder migrationBuilder)
{
- migrationBuilder.AddColumn(
- 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(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- name = table.Column(type: "text", nullable: false, comment: "Название папки"),
- id_parent = table.Column(type: "integer", nullable: true, comment: "Родительская папки"),
- id_category = table.Column(type: "integer", nullable: false, comment: "Категория")
+ name = table.Column(type: "text", nullable: false, comment: "Название"),
+ id_parent = table.Column(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(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- name = table.Column(type: "text", nullable: false, comment: "Название файла"),
- date_download = table.Column(type: "timestamp with time zone", nullable: false, comment: "Дата загрузки файла"),
- id_category = table.Column(type: "integer", nullable: true, comment: "Категория"),
- id_folder = table.Column(type: "integer", nullable: true, comment: "Id папки инструкций")
+ name = table.Column(type: "text", nullable: false, comment: "Название"),
+ date_download = table.Column(type: "timestamp with time zone", nullable: false, comment: "Дата загрузки"),
+ id_directory = table.Column(type: "integer", nullable: false, comment: "Id директории"),
+ id_category = table.Column(type: "integer", nullable: false, comment: "Id категории файла"),
+ id_author = table.Column(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");
}
}
}
diff --git a/AsbCloudDb/Migrations/AsbCloudDbContextModelSnapshot.cs b/AsbCloudDb/Migrations/AsbCloudDbContextModelSnapshot.cs
index 8e4119cc..5e03a24a 100644
--- a/AsbCloudDb/Migrations/AsbCloudDbContextModelSnapshot.cs
+++ b/AsbCloudDb/Migrations/AsbCloudDbContextModelSnapshot.cs
@@ -432,11 +432,6 @@ namespace AsbCloudDb.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
- b.Property("IdType")
- .HasColumnType("integer")
- .HasColumnName("type")
- .HasComment("0 = Инструкции");
-
b.Property("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("DateDownload")
.HasColumnType("timestamp with time zone")
.HasColumnName("date_download")
- .HasComment("Дата загрузки файла");
+ .HasComment("Дата загрузки");
- b.Property("IdCategory")
+ b.Property("IdAuthor")
+ .HasColumnType("integer")
+ .HasColumnName("id_author")
+ .HasComment("Id автора");
+
+ b.Property("IdCategory")
.HasColumnType("integer")
.HasColumnName("id_category")
- .HasComment("Категория");
+ .HasComment("Id категории файла");
- b.Property("IdFolder")
+ b.Property("IdDirectory")
.HasColumnType("integer")
- .HasColumnName("id_folder")
- .HasComment("Id папки инструкций");
+ .HasColumnName("id_directory")
+ .HasComment("Id директории");
b.Property("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("Id")
.ValueGeneratedOnAdd()
@@ -1133,31 +1128,24 @@ namespace AsbCloudDb.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
- b.Property("IdCategory")
- .HasColumnType("integer")
- .HasColumnName("id_category")
- .HasComment("Категория");
-
b.Property("IdParent")
.HasColumnType("integer")
.HasColumnName("id_parent")
- .HasComment("Родительская папки");
+ .HasComment("Id родительской директории");
b.Property("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");
diff --git a/AsbCloudDb/Model/AsbCloudDbContext.cs b/AsbCloudDb/Model/AsbCloudDbContext.cs
index d221a750..af24b47e 100644
--- a/AsbCloudDb/Model/AsbCloudDbContext.cs
+++ b/AsbCloudDb/Model/AsbCloudDbContext.cs
@@ -79,7 +79,7 @@ namespace AsbCloudDb.Model
public DbSet Notifications => Set();
public DbSet NotificationCategories => Set();
public DbSet Manuals => Set();
- public DbSet ManualFolders => Set();
+ public DbSet ManualDirectories => Set();
public AsbCloudDbContext() : base()
@@ -392,16 +392,16 @@ namespace AsbCloudDb.Model
entity.HasKey(x => new { x.IdWell, x.IdUser });
});
- modelBuilder.Entity()
+ modelBuilder.Entity()
.HasOne(mf => mf.Parent)
.WithMany(mf => mf.Children)
.HasForeignKey(mf => mf.IdParent)
.OnDelete(DeleteBehavior.Cascade);
modelBuilder.Entity()
- .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);
diff --git a/AsbCloudDb/Model/DefaultData/EntityFillerFileCategory.cs b/AsbCloudDb/Model/DefaultData/EntityFillerFileCategory.cs
index 00e56c06..39ddc2eb 100644
--- a/AsbCloudDb/Model/DefaultData/EntityFillerFileCategory.cs
+++ b/AsbCloudDb/Model/DefaultData/EntityFillerFileCategory.cs
@@ -74,9 +74,8 @@
new () {Id = 10043, Name = "Фактические данные бурения (вставляются в паспорт скважины)"},
new () {Id = 20000, Name = "Справки по страницам"},
-
- new() { Id = 30000, Name = "АСУ ТП", IdType = FileCategory.IdFileCategoryTypeManuals},
- new() { Id = 30001, Name = "Технология бурения", IdType = FileCategory.IdFileCategoryTypeManuals}
+
+ new() { Id = 30000, Name = "Инструкции"},
};
}
}
diff --git a/AsbCloudDb/Model/DefaultData/EntityFillerPermission.cs b/AsbCloudDb/Model/DefaultData/EntityFillerPermission.cs
index 9d12d3b4..20064bb7 100644
--- a/AsbCloudDb/Model/DefaultData/EntityFillerPermission.cs
+++ b/AsbCloudDb/Model/DefaultData/EntityFillerPermission.cs
@@ -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 = "Разрешить получение инструкций"}
};
}
}
diff --git a/AsbCloudDb/Model/FileCategory.cs b/AsbCloudDb/Model/FileCategory.cs
index 5aba28d6..ca47394c 100644
--- a/AsbCloudDb/Model/FileCategory.cs
+++ b/AsbCloudDb/Model/FileCategory.cs
@@ -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; }
}
}
\ No newline at end of file
diff --git a/AsbCloudDb/Model/IAsbCloudDbContext.cs b/AsbCloudDb/Model/IAsbCloudDbContext.cs
index 5a23ec89..645d4d1f 100644
--- a/AsbCloudDb/Model/IAsbCloudDbContext.cs
+++ b/AsbCloudDb/Model/IAsbCloudDbContext.cs
@@ -72,7 +72,7 @@ namespace AsbCloudDb.Model
DbSet Notifications { get; }
DbSet NotificationCategories { get; }
DbSet Manuals { get; }
- DbSet ManualFolders { get; }
+ DbSet ManualDirectories { get; }
DatabaseFacade Database { get; }
Task RefreshMaterializedViewAsync(string mwName, CancellationToken token);
diff --git a/AsbCloudDb/Model/Manuals/Manual.cs b/AsbCloudDb/Model/Manuals/Manual.cs
index 29bc1371..35b091b5 100644
--- a/AsbCloudDb/Model/Manuals/Manual.cs
+++ b/AsbCloudDb/Model/Manuals/Manual.cs
@@ -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; }
- [ForeignKey(nameof(IdCategory))]
- public virtual FileCategory? Category { get; set; }
+ [Column("id_directory"), Comment("Id директории")]
+ public int IdDirectory { get; set; }
- [Column("id_folder"), Comment("Id папки инструкций")]
- public int? IdFolder { get; set; }
+ [Column("id_category"), Comment("Id категории файла")]
+ public int IdCategory { get; set; }
- [ForeignKey(nameof(IdFolder))]
- public virtual ManualFolder? Folder { 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; } = null!;
+
+ [ForeignKey(nameof(IdAuthor))]
+ public virtual User Author { get; set; } = null!;
}
\ No newline at end of file
diff --git a/AsbCloudDb/Model/Manuals/ManualDirectory.cs b/AsbCloudDb/Model/Manuals/ManualDirectory.cs
new file mode 100644
index 00000000..b553eb67
--- /dev/null
+++ b/AsbCloudDb/Model/Manuals/ManualDirectory.cs
@@ -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? Children { get; set; }
+
+ public virtual ICollection? Manuals { get; set; }
+}
\ No newline at end of file
diff --git a/AsbCloudDb/Model/Manuals/ManualFolder.cs b/AsbCloudDb/Model/Manuals/ManualFolder.cs
deleted file mode 100644
index a3ea9647..00000000
--- a/AsbCloudDb/Model/Manuals/ManualFolder.cs
+++ /dev/null
@@ -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? Children { get; set; }
-
- public virtual ICollection? Manuals { get; set; }
-}
\ No newline at end of file