feat(api, generatorTemplates): в таблицу Works добавлено поле TemplateSuffix, из него в генераторе формируется имя шаблона.

This commit is contained in:
Mikhail Trubnikov
2024-06-14 14:27:37 +10:00
parent 6e3e3b4b95
commit cc71a8774b
10 changed files with 5540 additions and 1 deletions

View File

@@ -3,6 +3,7 @@
public class WorkRequest public class WorkRequest
{ {
public required string Name { get; set; } public required string Name { get; set; }
public string? TemplateSuffix { get;set; }
public int EsppId { get; set; } public int EsppId { get; set; }
public Guid TnkId { get; set; } public Guid TnkId { get; set; }
} }

View File

@@ -6,6 +6,8 @@
public required string Name { get; set; } public required string Name { get; set; }
public string? TemplateSuffix { get; set; }
public int EsppId { get; set; } public int EsppId { get; set; }
public Guid TnkId { get; set; } public Guid TnkId { get; set; }

View File

@@ -139,6 +139,7 @@ namespace PARR.API.Controllers.V1
Name = request.Name.Trim(), Name = request.Name.Trim(),
EsppId = request.EsppId, EsppId = request.EsppId,
TnkId = request.TnkId, TnkId = request.TnkId,
TemplateSuffix = request.TemplateSuffix
}; };
if (!await workService.CreateAsync(work) || !await workService.CommitAsync()) if (!await workService.CreateAsync(work) || !await workService.CommitAsync())
@@ -181,6 +182,7 @@ namespace PARR.API.Controllers.V1
orig.EsppId = request.EsppId; orig.EsppId = request.EsppId;
orig.TnkId = request.TnkId; orig.TnkId = request.TnkId;
orig.DateModified = DateTimeOffset.UtcNow; orig.DateModified = DateTimeOffset.UtcNow;
orig.TemplateSuffix = request.TemplateSuffix;
if (!await workService.CommitAsync()) if (!await workService.CommitAsync())
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка записи в базу данных изменений вида работ." } })); return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка записи в базу данных изменений вида работ." } }));

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class tblWorksAddShortName : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ShortName",
table: "Works",
type: "text",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ShortName",
table: "Works");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PARR.DAL.Migrations
{
/// <inheritdoc />
public partial class tblWorksRenameShortNameToTemplateSuffix : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "ShortName",
table: "Works",
newName: "TemplateSuffix");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "TemplateSuffix",
table: "Works",
newName: "ShortName");
}
}
}

View File

@@ -2208,6 +2208,9 @@ namespace PARR.DAL.Migrations
.IsRequired() .IsRequired()
.HasColumnType("text"); .HasColumnType("text");
b.Property<string>("TemplateSuffix")
.HasColumnType("text");
b.Property<Guid>("TnkId") b.Property<Guid>("TnkId")
.HasColumnType("uuid"); .HasColumnType("uuid");

View File

@@ -18,6 +18,11 @@ namespace PARR.DAL.Models
public required string Name { get; set; } public required string Name { get; set; }
/// <summary>
/// Короткое имя, для формирования имени шаблона
/// </summary>
public string? TemplateSuffix { get; set; }
public int EsppId { get; set; } public int EsppId { get; set; }
public Guid TnkId { get; set; } public Guid TnkId { get; set; }

View File

@@ -112,7 +112,15 @@ namespace PARR.GeneratorTemplates.Services
Id = Guid.NewGuid(), Id = Guid.NewGuid(),
//TODO:!!! //TODO:!!!
//Name = TemplateHelpers.GenerateTemplateName("ЗО" ,settingsFromDb.TemplatePrefixName, host.Ek, appInWork.Work!.Name), //Name = TemplateHelpers.GenerateTemplateName("ЗО" ,settingsFromDb.TemplatePrefixName, host.Ek, appInWork.Work!.Name),
Name = TemplateHelpers.GenerateTemplateNameWithResponseArea(host.ResponseArea!.Name, settingsFromDb.TemplatePrefixName, host.Ek, appInWork.Work!.Name.ApplyShortcode(Constants.Shortcode.Shortcodes.EK, host.Ek)), //Генерить имя с полным именем работы и подстановкой ЭК
//Name = TemplateHelpers.GenerateTemplateNameWithResponseArea(host.ResponseArea!.Name, settingsFromDb.TemplatePrefixName, host.Ek, appInWork.Work!.Name.ApplyShortcode(Constants.Shortcode.Shortcodes.EK, host.Ek)),
//Вместо полного имени работы, подставляется сокращенный суффикс или полное имя с ЭК если суффикса нет
Name = TemplateHelpers.GenerateTemplateNameWithResponseArea(
host.ResponseArea!.Name,
settingsFromDb.TemplatePrefixName,
host.Ek,
appInWork.Work!.TemplateSuffix ?? appInWork.Work!.Name.ApplyShortcode(Constants.Shortcode.Shortcodes.EK, host.Ek)
),
//IsActiveTemplate = true, //IsActiveTemplate = true,
//IsActiveSchedule = true, //IsActiveSchedule = true,
IsActiveTemplate = query.IsActiveTemplate ?? false, IsActiveTemplate = query.IsActiveTemplate ?? false,