feat(api, generatorTemplates): в таблицу Works добавлено поле TemplateSuffix, из него в генераторе формируется имя шаблона.
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
public class WorkRequest
|
||||
{
|
||||
public required string Name { get; set; }
|
||||
public string? TemplateSuffix { get;set; }
|
||||
public int EsppId { get; set; }
|
||||
public Guid TnkId { get; set; }
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
public required string Name { get; set; }
|
||||
|
||||
public string? TemplateSuffix { get; set; }
|
||||
|
||||
public int EsppId { get; set; }
|
||||
|
||||
public Guid TnkId { get; set; }
|
||||
|
||||
@@ -139,6 +139,7 @@ namespace PARR.API.Controllers.V1
|
||||
Name = request.Name.Trim(),
|
||||
EsppId = request.EsppId,
|
||||
TnkId = request.TnkId,
|
||||
TemplateSuffix = request.TemplateSuffix
|
||||
};
|
||||
|
||||
if (!await workService.CreateAsync(work) || !await workService.CommitAsync())
|
||||
@@ -181,6 +182,7 @@ namespace PARR.API.Controllers.V1
|
||||
orig.EsppId = request.EsppId;
|
||||
orig.TnkId = request.TnkId;
|
||||
orig.DateModified = DateTimeOffset.UtcNow;
|
||||
orig.TemplateSuffix = request.TemplateSuffix;
|
||||
|
||||
if (!await workService.CommitAsync())
|
||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка записи в базу данных изменений вида работ." } }));
|
||||
|
||||
2731
PARR.DAL/Migrations/20240614034149_tblWorksAddShortName.Designer.cs
generated
Normal file
2731
PARR.DAL/Migrations/20240614034149_tblWorksAddShortName.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
28
PARR.DAL/Migrations/20240614034149_tblWorksAddShortName.cs
Normal file
28
PARR.DAL/Migrations/20240614034149_tblWorksAddShortName.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
2731
PARR.DAL/Migrations/20240614041536_tblWorksRenameShortNameToTemplateSuffix.Designer.cs
generated
Normal file
2731
PARR.DAL/Migrations/20240614041536_tblWorksRenameShortNameToTemplateSuffix.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2208,6 +2208,9 @@ namespace PARR.DAL.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("TemplateSuffix")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("TnkId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
|
||||
@@ -18,6 +18,11 @@ namespace PARR.DAL.Models
|
||||
|
||||
public required string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Короткое имя, для формирования имени шаблона
|
||||
/// </summary>
|
||||
public string? TemplateSuffix { get; set; }
|
||||
|
||||
public int EsppId { get; set; }
|
||||
|
||||
public Guid TnkId { get; set; }
|
||||
|
||||
@@ -112,7 +112,15 @@ namespace PARR.GeneratorTemplates.Services
|
||||
Id = Guid.NewGuid(),
|
||||
//TODO:!!!
|
||||
//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,
|
||||
//IsActiveSchedule = true,
|
||||
IsActiveTemplate = query.IsActiveTemplate ?? false,
|
||||
|
||||
Reference in New Issue
Block a user