forked from ddrilling/AsbCloudServer
#5998816 дело скважины, исправления
This commit is contained in:
parent
2d0fe6245b
commit
c4d88401fd
@ -12,12 +12,12 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// полное название
|
/// полное название
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Name { get; set; }
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// сокращенное название
|
/// сокращенное название
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ShortName { get; set; }
|
public string ShortName { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
#nullable disable
|
#nullable disable
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,8 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// DTO Дело скважины
|
/// DTO Дело скважины
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class WellFinalDocumentsDBDto : IId
|
public class WellFinalDocumentDBDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Идентификатор
|
|
||||||
/// </summary>
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Идентификатор скважины
|
/// Идентификатор скважины
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -25,11 +20,6 @@
|
|||||||
/// Идентификатор категории файла
|
/// Идентификатор категории файла
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int IdCategory { get; set; }
|
public int IdCategory { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Идентификатор файла
|
|
||||||
/// </summary>
|
|
||||||
public int? IdFile { get; set; }
|
|
||||||
}
|
}
|
||||||
#nullable disable
|
#nullable disable
|
||||||
}
|
}
|
@ -7,7 +7,7 @@ namespace AsbCloudApp.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// DTO Документ дела скважины
|
/// DTO Документ дела скважины
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class WellFinalDocumentsDto
|
public class WellFinalDocumentDto
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Скважина
|
/// Скважина
|
||||||
@ -17,7 +17,7 @@ namespace AsbCloudApp.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Наименование категории файла
|
/// Наименование категории файла
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string NameCategory { get; set; }
|
public string NameCategory { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Список ответственных
|
/// Список ответственных
|
||||||
@ -32,7 +32,7 @@ namespace AsbCloudApp.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Актуальный файл
|
/// Актуальный файл
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FileInfoDto File { get; set; }
|
public FileInfoDto? File { get; set; }
|
||||||
}
|
}
|
||||||
#nullable disable
|
#nullable disable
|
||||||
}
|
}
|
23
AsbCloudApp/Data/WellFinalDocumentInputDto.cs
Normal file
23
AsbCloudApp/Data/WellFinalDocumentInputDto.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace AsbCloudApp.Data
|
||||||
|
{
|
||||||
|
#nullable enable
|
||||||
|
/// <summary>
|
||||||
|
/// DTO Для сохранения категорий дела скважины
|
||||||
|
/// </summary>
|
||||||
|
public class WellFinalDocumentInputDto
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Идентификатор категории файла
|
||||||
|
/// </summary>
|
||||||
|
public int IdCategory { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Список ответственных
|
||||||
|
/// </summary>
|
||||||
|
public IEnumerable<int> IdsPublishers { get; set; } = Enumerable.Empty<int>();
|
||||||
|
}
|
||||||
|
#nullable disable
|
||||||
|
}
|
@ -21,7 +21,7 @@ namespace AsbCloudApp.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Файлы
|
/// Файлы
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<FileInfoDto> File { get; set; }
|
public IEnumerable<FileInfoDto>? File { get; set; }
|
||||||
}
|
}
|
||||||
#nullable disable
|
#nullable disable
|
||||||
}
|
}
|
||||||
|
@ -167,5 +167,13 @@ namespace AsbCloudApp.Services
|
|||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<FileInfoDto>> GetInfoByIdsAsync(List<int> idsFile, CancellationToken token);
|
Task<List<FileInfoDto>> GetInfoByIdsAsync(List<int> idsFile, CancellationToken token);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Получение файлов по скважине
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<IEnumerable<FileInfoDto>> GetInfosByWellIdAsync(int idWell, CancellationToken token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,15 +10,24 @@ namespace AsbCloudApp.Services
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сервис "Дело скважины"
|
/// Сервис "Дело скважины"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IWellFinalDocumentsService : ICrudService<WellFinalDocumentsDBDto>
|
public interface IWellFinalDocumentsService
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Обновление записей дела скважины
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="idWell"></param>
|
||||||
|
/// <param name="dtos"></param>
|
||||||
|
/// <param name="token"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<int> UpdateRangeAsync(int idWell, IEnumerable<WellFinalDocumentInputDto>? dtos, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение всех записей
|
/// Получение всех записей
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name = "idWell" ></param >
|
/// <param name = "idWell" ></param >
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<WellFinalDocumentsDto>> GetByWellId(int idWell, CancellationToken token);
|
Task<IEnumerable<WellFinalDocumentDto>> GetByWellId(int idWell, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение списка ответственных
|
/// Получение списка ответственных
|
||||||
@ -26,7 +35,7 @@ namespace AsbCloudApp.Services
|
|||||||
/// <param name="idWell"></param>
|
/// <param name="idWell"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<IEnumerable<UserDto>> GetPublishersAsync(int idWell, CancellationToken token);
|
Task<IEnumerable<UserDto>> GetAvailableUsersAsync(int idWell, CancellationToken token);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получение истории файлов
|
/// Получение истории файлов
|
||||||
@ -46,7 +55,7 @@ namespace AsbCloudApp.Services
|
|||||||
/// <param name="fileName"></param>
|
/// <param name="fileName"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> SaveCategoryFile(int idDto, int idUser, Stream fileStream, string fileName, CancellationToken token);
|
Task<int> SaveCategoryFile(int idWell, int idCategory, int idUser, Stream fileStream, string fileName, CancellationToken token);
|
||||||
}
|
}
|
||||||
#nullable disable
|
#nullable disable
|
||||||
}
|
}
|
@ -4205,7 +4205,7 @@ namespace AsbCloudDb.Migrations
|
|||||||
b.HasComment("Композитная скважина");
|
b.HasComment("Композитная скважина");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AsbCloudDb.Model.WellFinalDocuments", b =>
|
modelBuilder.Entity("AsbCloudDb.Model.WellFinalDocument", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@ -6335,7 +6335,7 @@ namespace AsbCloudDb.Migrations
|
|||||||
b.Navigation("WellSrc");
|
b.Navigation("WellSrc");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AsbCloudDb.Model.WellFinalDocuments", b =>
|
modelBuilder.Entity("AsbCloudDb.Model.WellFinalDocument", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("AsbCloudDb.Model.FileCategory", "Category")
|
b.HasOne("AsbCloudDb.Model.FileCategory", "Category")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
|
@ -1892,19 +1892,19 @@ namespace AsbCloudDb.Migrations
|
|||||||
{
|
{
|
||||||
Id = 503,
|
Id = 503,
|
||||||
Description = "Разрешение удалять Дело скважины",
|
Description = "Разрешение удалять Дело скважины",
|
||||||
Name = "WellFinalDocuments.delete"
|
Name = "WellFinalDocument.delete"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 504,
|
Id = 504,
|
||||||
Description = "Разрешение редактировать Дело скважины",
|
Description = "Разрешение редактировать Дело скважины",
|
||||||
Name = "WellFinalDocuments.edit"
|
Name = "WellFinalDocument.edit"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 505,
|
Id = 505,
|
||||||
Description = "Разрешение просматривать Дело скважины",
|
Description = "Разрешение просматривать Дело скважины",
|
||||||
Name = "WellFinalDocuments.get"
|
Name = "WellFinalDocument.get"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -4271,7 +4271,7 @@ namespace AsbCloudDb.Migrations
|
|||||||
b.HasComment("Композитная скважина");
|
b.HasComment("Композитная скважина");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AsbCloudDb.Model.WellFinalDocuments", b =>
|
modelBuilder.Entity("AsbCloudDb.Model.WellFinalDocument", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@ -6401,7 +6401,7 @@ namespace AsbCloudDb.Migrations
|
|||||||
b.Navigation("WellSrc");
|
b.Navigation("WellSrc");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AsbCloudDb.Model.WellFinalDocuments", b =>
|
modelBuilder.Entity("AsbCloudDb.Model.WellFinalDocument", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("AsbCloudDb.Model.FileCategory", "Category")
|
b.HasOne("AsbCloudDb.Model.FileCategory", "Category")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
|
@ -16,9 +16,9 @@ namespace AsbCloudDb.Migrations
|
|||||||
{ 500, "Разрешение удалять Категорий документов файлов", "FileCategory.delete" },
|
{ 500, "Разрешение удалять Категорий документов файлов", "FileCategory.delete" },
|
||||||
{ 501, "Разрешение редактировать Категорий документов файлов", "FileCategory.edit" },
|
{ 501, "Разрешение редактировать Категорий документов файлов", "FileCategory.edit" },
|
||||||
{ 502, "Разрешение просматривать Категорий документов файлов", "FileCategory.get" },
|
{ 502, "Разрешение просматривать Категорий документов файлов", "FileCategory.get" },
|
||||||
{ 503, "Разрешение удалять Дело скважины", "WellFinalDocuments.delete" },
|
{ 503, "Разрешение удалять Дело скважины", "WellFinalDocument.delete" },
|
||||||
{ 504, "Разрешение редактировать Дело скважины", "WellFinalDocuments.edit" },
|
{ 504, "Разрешение редактировать Дело скважины", "WellFinalDocument.edit" },
|
||||||
{ 505, "Разрешение просматривать Дело скважины", "WellFinalDocuments.get" }
|
{ 505, "Разрешение просматривать Дело скважины", "WellFinalDocument.get" }
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.InsertData(
|
migrationBuilder.InsertData(
|
||||||
|
6642
AsbCloudDb/Migrations/20220909060026_Update_t_well_final_documents_r.Designer.cs
generated
Normal file
6642
AsbCloudDb/Migrations/20220909060026_Update_t_well_final_documents_r.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,85 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace AsbCloudDb.Migrations
|
||||||
|
{
|
||||||
|
public partial class Update_t_well_final_documents_r : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_t_well_final_documents_t_file_info_id_file",
|
||||||
|
table: "t_well_final_documents");
|
||||||
|
|
||||||
|
migrationBuilder.DropPrimaryKey(
|
||||||
|
name: "t_well_final_documents_pk",
|
||||||
|
table: "t_well_final_documents");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_t_well_final_documents_id_file",
|
||||||
|
table: "t_well_final_documents");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_t_well_final_documents_id_well",
|
||||||
|
table: "t_well_final_documents");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "id",
|
||||||
|
table: "t_well_final_documents");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "id_file",
|
||||||
|
table: "t_well_final_documents");
|
||||||
|
|
||||||
|
migrationBuilder.AddPrimaryKey(
|
||||||
|
name: "t_well_final_documents_pk",
|
||||||
|
table: "t_well_final_documents",
|
||||||
|
columns: new[] { "id_well", "id_user", "id_category" });
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropPrimaryKey(
|
||||||
|
name: "t_well_final_documents_pk",
|
||||||
|
table: "t_well_final_documents");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "id",
|
||||||
|
table: "t_well_final_documents",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "id_file",
|
||||||
|
table: "t_well_final_documents",
|
||||||
|
type: "integer",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddPrimaryKey(
|
||||||
|
name: "t_well_final_documents_pk",
|
||||||
|
table: "t_well_final_documents",
|
||||||
|
column: "id");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_t_well_final_documents_id_file",
|
||||||
|
table: "t_well_final_documents",
|
||||||
|
column: "id_file");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_t_well_final_documents_id_well",
|
||||||
|
table: "t_well_final_documents",
|
||||||
|
column: "id_well");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_t_well_final_documents_t_file_info_id_file",
|
||||||
|
table: "t_well_final_documents",
|
||||||
|
column: "id_file",
|
||||||
|
principalTable: "t_file_info",
|
||||||
|
principalColumn: "id");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1890,19 +1890,19 @@ namespace AsbCloudDb.Migrations
|
|||||||
{
|
{
|
||||||
Id = 503,
|
Id = 503,
|
||||||
Description = "Разрешение удалять Дело скважины",
|
Description = "Разрешение удалять Дело скважины",
|
||||||
Name = "WellFinalDocuments.delete"
|
Name = "WellFinalDocument.delete"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 504,
|
Id = 504,
|
||||||
Description = "Разрешение редактировать Дело скважины",
|
Description = "Разрешение редактировать Дело скважины",
|
||||||
Name = "WellFinalDocuments.edit"
|
Name = "WellFinalDocument.edit"
|
||||||
},
|
},
|
||||||
new
|
new
|
||||||
{
|
{
|
||||||
Id = 505,
|
Id = 505,
|
||||||
Description = "Разрешение просматривать Дело скважины",
|
Description = "Разрешение просматривать Дело скважины",
|
||||||
Name = "WellFinalDocuments.get"
|
Name = "WellFinalDocument.get"
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -4269,42 +4269,27 @@ namespace AsbCloudDb.Migrations
|
|||||||
b.HasComment("Композитная скважина");
|
b.HasComment("Композитная скважина");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AsbCloudDb.Model.WellFinalDocuments", b =>
|
modelBuilder.Entity("AsbCloudDb.Model.WellFinalDocument", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("IdWell")
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("integer")
|
.HasColumnType("integer")
|
||||||
.HasColumnName("id");
|
.HasColumnName("id_well");
|
||||||
|
|
||||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int>("IdCategory")
|
|
||||||
.HasColumnType("integer")
|
|
||||||
.HasColumnName("id_category");
|
|
||||||
|
|
||||||
b.Property<int?>("IdFile")
|
|
||||||
.HasColumnType("integer")
|
|
||||||
.HasColumnName("id_file");
|
|
||||||
|
|
||||||
b.Property<int>("IdUser")
|
b.Property<int>("IdUser")
|
||||||
.HasColumnType("integer")
|
.HasColumnType("integer")
|
||||||
.HasColumnName("id_user");
|
.HasColumnName("id_user");
|
||||||
|
|
||||||
b.Property<int>("IdWell")
|
b.Property<int>("IdCategory")
|
||||||
.HasColumnType("integer")
|
.HasColumnType("integer")
|
||||||
.HasColumnName("id_well");
|
.HasColumnName("id_category");
|
||||||
|
|
||||||
b.HasKey("Id")
|
b.HasKey("IdWell", "IdUser", "IdCategory")
|
||||||
.HasName("t_well_final_documents_pk");
|
.HasName("t_well_final_documents_pk");
|
||||||
|
|
||||||
b.HasIndex("IdCategory");
|
b.HasIndex("IdCategory");
|
||||||
|
|
||||||
b.HasIndex("IdFile");
|
|
||||||
|
|
||||||
b.HasIndex("IdUser");
|
b.HasIndex("IdUser");
|
||||||
|
|
||||||
b.HasIndex("IdWell");
|
|
||||||
|
|
||||||
b.ToTable("t_well_final_documents");
|
b.ToTable("t_well_final_documents");
|
||||||
|
|
||||||
b.HasComment("Дело скважины");
|
b.HasComment("Дело скважины");
|
||||||
@ -6399,7 +6384,7 @@ namespace AsbCloudDb.Migrations
|
|||||||
b.Navigation("WellSrc");
|
b.Navigation("WellSrc");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("AsbCloudDb.Model.WellFinalDocuments", b =>
|
modelBuilder.Entity("AsbCloudDb.Model.WellFinalDocument", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("AsbCloudDb.Model.FileCategory", "Category")
|
b.HasOne("AsbCloudDb.Model.FileCategory", "Category")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
@ -6407,10 +6392,6 @@ namespace AsbCloudDb.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("AsbCloudDb.Model.FileInfo", "File")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("IdFile");
|
|
||||||
|
|
||||||
b.HasOne("AsbCloudDb.Model.User", "User")
|
b.HasOne("AsbCloudDb.Model.User", "User")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("IdUser")
|
.HasForeignKey("IdUser")
|
||||||
@ -6425,8 +6406,6 @@ namespace AsbCloudDb.Migrations
|
|||||||
|
|
||||||
b.Navigation("Category");
|
b.Navigation("Category");
|
||||||
|
|
||||||
b.Navigation("File");
|
|
||||||
|
|
||||||
b.Navigation("User");
|
b.Navigation("User");
|
||||||
|
|
||||||
b.Navigation("Well");
|
b.Navigation("Well");
|
||||||
|
@ -47,7 +47,7 @@ namespace AsbCloudDb.Model
|
|||||||
public virtual DbSet<Driller> Drillers => Set<Driller>();
|
public virtual DbSet<Driller> Drillers => Set<Driller>();
|
||||||
public virtual DbSet<Schedule> Schedule => Set<Schedule>();
|
public virtual DbSet<Schedule> Schedule => Set<Schedule>();
|
||||||
public virtual DbSet<OperationValue> OperationValues => Set<OperationValue>();
|
public virtual DbSet<OperationValue> OperationValues => Set<OperationValue>();
|
||||||
public virtual DbSet<WellFinalDocuments> WellFinalDocuments => Set<WellFinalDocuments>();
|
public virtual DbSet<WellFinalDocument> WellFinalDocuments => Set<WellFinalDocument>();
|
||||||
|
|
||||||
// WITS
|
// WITS
|
||||||
public DbSet<WITS.Record1> Record1 => Set<WITS.Record1>();
|
public DbSet<WITS.Record1> Record1 => Set<WITS.Record1>();
|
||||||
@ -343,6 +343,12 @@ namespace AsbCloudDb.Model
|
|||||||
entity.HasKey(nameof(UserSetting.IdUser), nameof(UserSetting.Key));
|
entity.HasKey(nameof(UserSetting.IdUser), nameof(UserSetting.Key));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<WellFinalDocument>(entity =>
|
||||||
|
{
|
||||||
|
entity.HasKey(x => new { x.IdWell, x.IdUser, x.IdCategory })
|
||||||
|
.HasName("t_well_final_documents_pk");
|
||||||
|
});
|
||||||
|
|
||||||
DefaultData.DefaultContextData.Fill(modelBuilder);
|
DefaultData.DefaultContextData.Fill(modelBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,9 +126,9 @@
|
|||||||
new (){ Id = 500, Name="FileCategory.delete", Description="Разрешение удалять Категорий документов файлов"},
|
new (){ Id = 500, Name="FileCategory.delete", Description="Разрешение удалять Категорий документов файлов"},
|
||||||
new (){ Id = 501, Name="FileCategory.edit", Description="Разрешение редактировать Категорий документов файлов"},
|
new (){ Id = 501, Name="FileCategory.edit", Description="Разрешение редактировать Категорий документов файлов"},
|
||||||
new (){ Id = 502, Name="FileCategory.get", Description="Разрешение просматривать Категорий документов файлов"},
|
new (){ Id = 502, Name="FileCategory.get", Description="Разрешение просматривать Категорий документов файлов"},
|
||||||
new (){ Id = 503, Name="WellFinalDocuments.delete", Description="Разрешение удалять Дело скважины"},
|
new (){ Id = 503, Name="WellFinalDocument.delete", Description="Разрешение удалять Дело скважины"},
|
||||||
new (){ Id = 504, Name="WellFinalDocuments.edit", Description="Разрешение редактировать Дело скважины"},
|
new (){ Id = 504, Name="WellFinalDocument.edit", Description="Разрешение редактировать Дело скважины"},
|
||||||
new (){ Id = 505, Name="WellFinalDocuments.get", Description="Разрешение просматривать Дело скважины"},
|
new (){ Id = 505, Name="WellFinalDocument.get", Description="Разрешение просматривать Дело скважины"},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ namespace AsbCloudDb.Model
|
|||||||
DbSet<Driller> Drillers { get; }
|
DbSet<Driller> Drillers { get; }
|
||||||
DbSet<Schedule> Schedule { get; }
|
DbSet<Schedule> Schedule { get; }
|
||||||
DbSet<OperationValue> OperationValues { get; }
|
DbSet<OperationValue> OperationValues { get; }
|
||||||
DbSet<WellFinalDocuments> WellFinalDocuments { get; }
|
DbSet<WellFinalDocument> WellFinalDocuments { get; }
|
||||||
|
|
||||||
DbSet<Record1> Record1 { get; }
|
DbSet<Record1> Record1 { get; }
|
||||||
DbSet<Record7> Record7 { get; }
|
DbSet<Record7> Record7 { get; }
|
||||||
|
@ -6,12 +6,8 @@ namespace AsbCloudDb.Model
|
|||||||
{
|
{
|
||||||
#nullable disable
|
#nullable disable
|
||||||
[Table("t_well_final_documents"), Comment("Дело скважины")]
|
[Table("t_well_final_documents"), Comment("Дело скважины")]
|
||||||
public class WellFinalDocuments : IId, IWellRelated
|
public class WellFinalDocument : IWellRelated
|
||||||
{
|
{
|
||||||
[Key]
|
|
||||||
[Column("id")]
|
|
||||||
public int Id { get; set; }
|
|
||||||
|
|
||||||
[Column("id_well")]
|
[Column("id_well")]
|
||||||
public int IdWell { get; set; }
|
public int IdWell { get; set; }
|
||||||
|
|
||||||
@ -21,9 +17,6 @@ namespace AsbCloudDb.Model
|
|||||||
[Column("id_category")]
|
[Column("id_category")]
|
||||||
public int IdCategory { get; set; }
|
public int IdCategory { get; set; }
|
||||||
|
|
||||||
[Column("id_file")]
|
|
||||||
public int? IdFile { get; set; }
|
|
||||||
|
|
||||||
[ForeignKey(nameof(IdWell))]
|
[ForeignKey(nameof(IdWell))]
|
||||||
public virtual Well Well { get; set; }
|
public virtual Well Well { get; set; }
|
||||||
|
|
||||||
@ -32,8 +25,5 @@ namespace AsbCloudDb.Model
|
|||||||
|
|
||||||
[ForeignKey(nameof(IdCategory))]
|
[ForeignKey(nameof(IdCategory))]
|
||||||
public virtual FileCategory Category { get; set; }
|
public virtual FileCategory Category { get; set; }
|
||||||
|
|
||||||
[ForeignKey(nameof(IdFile))]
|
|
||||||
public virtual FileInfo File { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -72,7 +72,7 @@ namespace AsbCloudInfrastructure
|
|||||||
.ForType<FileCategoryDto, FileCategory>();
|
.ForType<FileCategoryDto, FileCategory>();
|
||||||
|
|
||||||
TypeAdapterConfig.GlobalSettings.Default.Config
|
TypeAdapterConfig.GlobalSettings.Default.Config
|
||||||
.ForType<WellFinalDocumentsDto, WellFinalDocuments>();
|
.ForType<WellFinalDocumentDto, WellFinalDocument>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
|
public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration)
|
||||||
|
@ -363,5 +363,17 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<FileInfoDto>> GetInfosByWellIdAsync(int idWell, CancellationToken token)
|
||||||
|
{
|
||||||
|
var entities = await dbSetConfigured
|
||||||
|
.Where(e => e.IdWell == idWell && e.IsDeleted == false)
|
||||||
|
.AsNoTracking()
|
||||||
|
.ToListAsync(token)
|
||||||
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
|
var dtos = entities.Select(e => Convert(e));
|
||||||
|
return dtos;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ using AsbCloudApp.Exceptions;
|
|||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
using AsbCloudDb.Model;
|
||||||
using AsbCloudInfrastructure.Repository;
|
using AsbCloudInfrastructure.Repository;
|
||||||
|
using Mapster;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using System;
|
using System;
|
||||||
@ -14,10 +15,11 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace AsbCloudInfrastructure.Services
|
namespace AsbCloudInfrastructure.Services
|
||||||
{
|
{
|
||||||
|
#nullable enable
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сервис "Дело скважины"
|
/// Сервис "Дело скважины"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class WellFinalDocumentsService : CrudServiceBase<WellFinalDocumentsDBDto, WellFinalDocuments>, IWellFinalDocumentsService
|
public class WellFinalDocumentsService : IWellFinalDocumentsService
|
||||||
{
|
{
|
||||||
private readonly IAsbCloudDbContext context;
|
private readonly IAsbCloudDbContext context;
|
||||||
private readonly IFileService fileService;
|
private readonly IFileService fileService;
|
||||||
@ -26,7 +28,6 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
private readonly IConfiguration configuration;
|
private readonly IConfiguration configuration;
|
||||||
private readonly IEmailService emailService;
|
private readonly IEmailService emailService;
|
||||||
private readonly IFileCategoryService fileCategoryService;
|
private readonly IFileCategoryService fileCategoryService;
|
||||||
private const int ResultSaveCategoryFile = 0;
|
|
||||||
|
|
||||||
public WellFinalDocumentsService(IAsbCloudDbContext context,
|
public WellFinalDocumentsService(IAsbCloudDbContext context,
|
||||||
IFileService fileService,
|
IFileService fileService,
|
||||||
@ -35,7 +36,6 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
IConfiguration configuration,
|
IConfiguration configuration,
|
||||||
IEmailService emailService,
|
IEmailService emailService,
|
||||||
IFileCategoryService fileCategoryService)
|
IFileCategoryService fileCategoryService)
|
||||||
: base(context)
|
|
||||||
{
|
{
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.fileService = fileService;
|
this.fileService = fileService;
|
||||||
@ -46,38 +46,40 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
this.fileCategoryService = fileCategoryService;
|
this.fileCategoryService = fileCategoryService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<int> InsertRangeAsync(IEnumerable<WellFinalDocumentsDBDto> dtos, CancellationToken token)
|
public async Task<int> UpdateRangeAsync(int idWell, IEnumerable<WellFinalDocumentInputDto>? dtos, CancellationToken token)
|
||||||
{
|
{
|
||||||
var data = await base.InsertRangeAsync(dtos, token);
|
if (dtos is not null)
|
||||||
if (data > 0)
|
|
||||||
{
|
{
|
||||||
var message = "от Вас ожидается загрузка на портал документа «{0}»";
|
var entities = dtos
|
||||||
await GenerateMessageAsync(dtos, message, token);
|
.Where(dto => dto.IdsPublishers?.Any() == true)
|
||||||
}
|
.SelectMany(dto => dto.IdsPublishers
|
||||||
|
.Select(idUser => new WellFinalDocument
|
||||||
|
{
|
||||||
|
IdCategory = dto.IdCategory,
|
||||||
|
IdWell = idWell,
|
||||||
|
IdUser = idUser
|
||||||
|
}));
|
||||||
|
|
||||||
return data;
|
var itemsToDelete = context.WellFinalDocuments.Where(d => d.IdWell == idWell);
|
||||||
|
context.WellFinalDocuments.RemoveRange(itemsToDelete);
|
||||||
|
|
||||||
|
await context.WellFinalDocuments.AddRangeAsync(entities).ConfigureAwait(false);
|
||||||
|
var data = await context.SaveChangesAsync(token).ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (data > 0)
|
||||||
|
{
|
||||||
|
var message = "от Вас ожидается загрузка на портал документа «{0}»";
|
||||||
|
await GenerateMessageAsync(entities.Select(x => Convert(x)), message, token);
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
throw new ArgumentInvalidException("Данные по категориям отсутствуют.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<int> DeleteAsync(int dtoId, CancellationToken token)
|
public async Task<IEnumerable<WellFinalDocumentDto>> GetByWellId(int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
var entity = await context.WellFinalDocuments
|
var result = new List<WellFinalDocumentDto>();
|
||||||
.AsNoTracking()
|
|
||||||
.FirstOrDefaultAsync(x => x.Id == dtoId);
|
|
||||||
var dto = Convert(entity);
|
|
||||||
|
|
||||||
var data = await base.DeleteAsync(dtoId, token);
|
|
||||||
if (data > 0)
|
|
||||||
{
|
|
||||||
var message = "Вас удалили из ответственных за загрузку документа «{0}»";
|
|
||||||
await GenerateMessageAsync(new List<WellFinalDocumentsDBDto> { dto }, message, token);
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<IEnumerable<WellFinalDocumentsDto>> GetByWellId(int idWell, CancellationToken token)
|
|
||||||
{
|
|
||||||
var result = new List<WellFinalDocumentsDto>();
|
|
||||||
|
|
||||||
var wells = await context.WellFinalDocuments.Where(x => x.IdWell == idWell)
|
var wells = await context.WellFinalDocuments.Where(x => x.IdWell == idWell)
|
||||||
.ToListAsync(token)
|
.ToListAsync(token)
|
||||||
@ -95,11 +97,14 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
fc => fc.Id,
|
fc => fc.Id,
|
||||||
w => w.IdCategory,
|
w => w.IdCategory,
|
||||||
(o, i) => new {
|
(o, i) => new {
|
||||||
|
IdCategory = o.Id,
|
||||||
NameCategory = o.Name,
|
NameCategory = o.Name,
|
||||||
Wells = i
|
Wells = i
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
var wellFiles = await fileService.GetInfosByWellIdAsync(idWell, token).ConfigureAwait(false);
|
||||||
|
|
||||||
wellFinalDocs.ForEach(async item => {
|
wellFinalDocs.ForEach(async item => {
|
||||||
var userIds = item.Wells
|
var userIds = item.Wells
|
||||||
.Select(x => x.IdUser)
|
.Select(x => x.IdUser)
|
||||||
@ -107,23 +112,20 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
var allUsers = await userService.GetAllAsync(token)
|
var allUsers = await userService.GetAllAsync(token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
var fileIds = item.Wells
|
var allFiles = wellFiles.Where(x => x.IdCategory == item.IdCategory);
|
||||||
.Where(x => x.IdFile != null)
|
|
||||||
.Select(x => x.IdFile)
|
FileInfoDto? actualFile = null;
|
||||||
.OrderByDescending(x => x)
|
if (allFiles.Any())
|
||||||
.ToList();
|
|
||||||
FileInfoDto actualFile = null;
|
|
||||||
if (fileIds.Any())
|
|
||||||
{
|
{
|
||||||
var actualFileId = fileIds.FirstOrDefault();
|
actualFile = allFiles.OrderByDescending(x => x.Id)
|
||||||
actualFile = fileService.GetInfoAsync(actualFileId ?? default(int), token).Result;
|
.FirstOrDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
result.Add(new WellFinalDocumentsDto {
|
result.Add(new WellFinalDocumentDto {
|
||||||
IdWell = idWell,
|
IdWell = idWell,
|
||||||
NameCategory = item.NameCategory,
|
NameCategory = item.NameCategory,
|
||||||
Publishers = allUsers.Where(x => userIds.Contains(x.Id)),
|
Publishers = allUsers.Where(x => userIds.Contains(x.Id)),
|
||||||
FilesCount = fileIds.Count(x => x.HasValue),
|
FilesCount = allFiles.Count(),
|
||||||
File = actualFile
|
File = actualFile
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -132,7 +134,7 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<UserDto>> GetPublishersAsync(int idWell, CancellationToken token)
|
public async Task<IEnumerable<UserDto>> GetAvailableUsersAsync(int idWell, CancellationToken token)
|
||||||
{
|
{
|
||||||
var companyIds = await context.RelationCompaniesWells
|
var companyIds = await context.RelationCompaniesWells
|
||||||
.Where(x => x.IdWell == idWell).Select(x => x.IdCompany)
|
.Where(x => x.IdWell == idWell).Select(x => x.IdCompany)
|
||||||
@ -150,13 +152,13 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<int> SaveCategoryFile(int idDto, int idUser, Stream fileStream, string fileName, CancellationToken token)
|
public async Task<int> SaveCategoryFile(int idWell, int idCategory, int idUser, Stream fileStream, string fileName, CancellationToken token)
|
||||||
{
|
{
|
||||||
var entity = await context.WellFinalDocuments
|
var entity = await context.WellFinalDocuments
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.FirstOrDefaultAsync(x => x.Id == idDto);
|
.FirstOrDefaultAsync(x => x.IdWell == idWell && x.IdCategory == idCategory && x.IdUser == idUser);
|
||||||
|
|
||||||
if (entity.IdUser != idUser)
|
if (entity is null)
|
||||||
throw new ArgumentInvalidException("Пользователь не является ответственным за загрузку файла для данной категории.");
|
throw new ArgumentInvalidException("Пользователь не является ответственным за загрузку файла для данной категории.");
|
||||||
|
|
||||||
var dto = Convert(entity);
|
var dto = Convert(entity);
|
||||||
@ -164,23 +166,12 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
var file = await fileService.SaveAsync(dto.IdWell, dto.IdUser, dto.IdCategory, fileName,
|
var file = await fileService.SaveAsync(dto.IdWell, dto.IdUser, dto.IdCategory, fileName,
|
||||||
fileStream, token).ConfigureAwait(false);
|
fileStream, token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (file is not null)
|
return file?.Id ?? -1;
|
||||||
{
|
|
||||||
dto.IdFile = file.Id;
|
|
||||||
return await base.UpdateAsync(dto, token);
|
|
||||||
}
|
|
||||||
else return ResultSaveCategoryFile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<WellFinalDocumentsHistoryDto> GetFilesHistoryByIdCategory(int idWell, int idCategory, CancellationToken token)
|
public async Task<WellFinalDocumentsHistoryDto> GetFilesHistoryByIdCategory(int idWell, int idCategory, CancellationToken token)
|
||||||
{
|
{
|
||||||
var wellsIds = await context.WellFinalDocuments
|
var files = await fileService.GetInfosByCategoryAsync(idWell, idCategory, token).ConfigureAwait(false);
|
||||||
.Where(x => idWell == x.IdWell && x.IdCategory == idCategory && x.IdFile != null)
|
|
||||||
.Select(x => (int)x.IdFile)
|
|
||||||
.ToListAsync(token)
|
|
||||||
.ConfigureAwait(false);
|
|
||||||
|
|
||||||
var files = await fileService.GetInfoByIdsAsync(wellsIds, token).ConfigureAwait(false);
|
|
||||||
|
|
||||||
return new WellFinalDocumentsHistoryDto {
|
return new WellFinalDocumentsHistoryDto {
|
||||||
IdWell = idWell,
|
IdWell = idWell,
|
||||||
@ -189,15 +180,18 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task GenerateMessageAsync(IEnumerable<WellFinalDocumentsDBDto> dtos, string message, CancellationToken token)
|
private async Task GenerateMessageAsync(IEnumerable<WellFinalDocumentDBDto> dtos, string message, CancellationToken token)
|
||||||
{
|
{
|
||||||
foreach (var item in dtos)
|
foreach (var item in dtos)
|
||||||
{
|
{
|
||||||
var user = await userService.GetOrDefaultAsync(item.IdUser, token);
|
var user = await userService.GetOrDefaultAsync(item.IdUser, token);
|
||||||
var category = await fileCategoryService.GetOrDefaultAsync(item.IdCategory, token);
|
if (user?.Email is not null)
|
||||||
var well = await wellService.GetOrDefaultAsync(item.IdWell, token);
|
{
|
||||||
|
var category = await fileCategoryService.GetOrDefaultAsync(item.IdCategory, token);
|
||||||
|
var well = await wellService.GetOrDefaultAsync(item.IdWell, token);
|
||||||
|
|
||||||
SendMessage(well, user, category.Name, message, token);
|
SendMessage(well, user, category.Name, message, token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,14 +203,11 @@ namespace AsbCloudInfrastructure.Services
|
|||||||
emailService.EnqueueSend(user.Email, subject, body);
|
emailService.EnqueueSend(user.Email, subject, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static WellFinalDocumentsDBDto Convert(WellFinalDocuments dto)
|
private WellFinalDocument Convert(WellFinalDocumentDBDto dto)
|
||||||
=> new WellFinalDocumentsDBDto
|
=> dto.Adapt<WellFinalDocument>();
|
||||||
{
|
|
||||||
Id = dto.Id,
|
private WellFinalDocumentDBDto Convert(WellFinalDocument entity)
|
||||||
IdCategory = dto.IdCategory,
|
=> entity.Adapt<WellFinalDocumentDBDto>();
|
||||||
IdWell = dto.IdWell,
|
|
||||||
IdUser = dto.IdUser,
|
|
||||||
IdFile = dto.IdFile
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
#nullable disable
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetListResponsibles_return_cnt_users()
|
public async Task GetListResponsibles_return_cnt_users()
|
||||||
{
|
{
|
||||||
var data = await service.GetPublishersAsync(90, CancellationToken.None);
|
var data = await service.GetAvailableUsersAsync(90, CancellationToken.None);
|
||||||
Assert.NotNull(data);
|
Assert.NotNull(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ namespace AsbCloudWebApi.Tests.ServicesTests
|
|||||||
public async Task SaveCategoryFile_return_id_edit_record()
|
public async Task SaveCategoryFile_return_id_edit_record()
|
||||||
{
|
{
|
||||||
var stream = new FileStream("D:\\test\\test.txt", FileMode.Open);
|
var stream = new FileStream("D:\\test\\test.txt", FileMode.Open);
|
||||||
var data = await service.SaveCategoryFile(21, 78, stream, "test.txt", CancellationToken.None);
|
var data = await service.SaveCategoryFile(21, 10018, 78, stream, "test.txt", CancellationToken.None);
|
||||||
Assert.Equal(21, data);
|
Assert.Equal(21, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,11 @@ using System.Threading.Tasks;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using AsbCloudInfrastructure.Services;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers
|
namespace AsbCloudWebApi.Controllers
|
||||||
{
|
{
|
||||||
|
#nullable enable
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дело скважины
|
/// Дело скважины
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -18,9 +20,11 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
public class WellFinalDocumentsController : ControllerBase
|
public class WellFinalDocumentsController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IWellFinalDocumentsService wellFinalDocumentsService;
|
private readonly IWellFinalDocumentsService wellFinalDocumentsService;
|
||||||
public WellFinalDocumentsController(IWellFinalDocumentsService wellFinalDocumentsService)
|
private readonly IWellService wellService;
|
||||||
|
public WellFinalDocumentsController(IWellFinalDocumentsService wellFinalDocumentsService, IWellService wellService)
|
||||||
{
|
{
|
||||||
this.wellFinalDocumentsService = wellFinalDocumentsService;
|
this.wellFinalDocumentsService = wellFinalDocumentsService;
|
||||||
|
this.wellService = wellService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -31,9 +35,13 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
[Permission]
|
[Permission]
|
||||||
[ProducesResponseType(typeof(IEnumerable<WellFinalDocumentsDto>), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(IEnumerable<WellFinalDocumentDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> GetAsync(int idWell, CancellationToken token = default)
|
public async Task<IActionResult> GetAsync(int idWell, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
|
var idCompany = User.GetCompanyId();
|
||||||
|
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync(idCompany ?? default, idWell, token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
var data = await this.wellFinalDocumentsService.GetByWellId(idWell, token);
|
var data = await this.wellFinalDocumentsService.GetByWellId(idWell, token);
|
||||||
return Ok(data);
|
return Ok(data);
|
||||||
}
|
}
|
||||||
@ -48,39 +56,29 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
[Permission]
|
[Permission]
|
||||||
[Route("publishers")]
|
[Route("publishers")]
|
||||||
[ProducesResponseType(typeof(IEnumerable<UserDto>), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(IEnumerable<UserDto>), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> GetPublishersAsync(int idWell, CancellationToken token = default)
|
public async Task<IActionResult> GetAvailableUsersAsync(int idWell, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var data = await this.wellFinalDocumentsService.GetPublishersAsync(idWell, token);
|
var idCompany = User.GetCompanyId();
|
||||||
|
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync(idCompany ?? default, idWell, token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
|
var data = await this.wellFinalDocumentsService.GetAvailableUsersAsync(idWell, token);
|
||||||
return Ok(data);
|
return Ok(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление записи
|
/// Добавление записи
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="idWell"></param>
|
||||||
/// <param name="dtos"></param>
|
/// <param name="dtos"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
[Permission]
|
[Permission]
|
||||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> InsertRangeAsync(IEnumerable<WellFinalDocumentsDBDto> dtos, CancellationToken token = default)
|
public async Task<IActionResult> UpdateRangeAsync(int idWell, IEnumerable<WellFinalDocumentInputDto> dtos, CancellationToken token = default)
|
||||||
{
|
{
|
||||||
var data = await this.wellFinalDocumentsService.InsertRangeAsync(dtos, token);
|
var data = await this.wellFinalDocumentsService.UpdateRangeAsync(idWell, dtos, token);
|
||||||
return Ok(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Удалить запись
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="iDdto"></param>
|
|
||||||
/// <param name="token"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[HttpDelete]
|
|
||||||
[Permission]
|
|
||||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
|
||||||
public async Task<IActionResult> DeleteAsync(int iDdto, CancellationToken token = default)
|
|
||||||
{
|
|
||||||
var data = await this.wellFinalDocumentsService.DeleteAsync(iDdto, token);
|
|
||||||
return Ok(data);
|
return Ok(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,6 +97,10 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
int idCategory,
|
int idCategory,
|
||||||
CancellationToken token = default)
|
CancellationToken token = default)
|
||||||
{
|
{
|
||||||
|
var idCompany = User.GetCompanyId();
|
||||||
|
if (idCompany is null || !await wellService.IsCompanyInvolvedInWellAsync(idCompany ?? default, idWell, token).ConfigureAwait(false))
|
||||||
|
return Forbid();
|
||||||
|
|
||||||
var data = await this.wellFinalDocumentsService.GetFilesHistoryByIdCategory(idWell, idCategory, token);
|
var data = await this.wellFinalDocumentsService.GetFilesHistoryByIdCategory(idWell, idCategory, token);
|
||||||
return Ok(data);
|
return Ok(data);
|
||||||
}
|
}
|
||||||
@ -106,20 +108,21 @@ namespace AsbCloudWebApi.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Сохранение файла
|
/// Сохранение файла
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idDto"></param>
|
/// <param name="idWell"></param>
|
||||||
/// <param name="idUser"></param>
|
/// <param name="idCategory"></param>
|
||||||
/// <param name="file"></param>
|
/// <param name="file"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Permission]
|
[Permission]
|
||||||
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
[ProducesResponseType(typeof(int), (int)System.Net.HttpStatusCode.OK)]
|
||||||
public async Task<IActionResult> SaveCategoryFile(int idDto, int idUser,
|
public async Task<IActionResult> SaveCategoryFile(int idWell, int idCategory, IFormFile file, CancellationToken token = default)
|
||||||
IFormFile file, CancellationToken token = default)
|
|
||||||
{
|
{
|
||||||
|
var idUser = User.GetUserId() ?? -1;
|
||||||
var fileStream = file.OpenReadStream();
|
var fileStream = file.OpenReadStream();
|
||||||
var data = await this.wellFinalDocumentsService.SaveCategoryFile(idDto, idUser, fileStream, file.FileName, token);
|
var data = await this.wellFinalDocumentsService.SaveCategoryFile(idWell, idCategory, idUser, fileStream, file.FileName, token);
|
||||||
return Ok(data);
|
return Ok(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#nullable disable
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user