feat(api, bll, dal, generatorTemplates, templateActivator): запись истории изменения шаблонов

This commit is contained in:
Mikhail Trubnikov
2024-10-08 10:29:34 +10:00
parent 54fed9b597
commit a494b69ee6
22 changed files with 140 additions and 67 deletions

View File

@@ -9,6 +9,7 @@ using PARR.API.Services.Interfaces;
using PARR.API.Settings;
using PARR.BLL.Domain.Mq;
using PARR.BLL.Services.Interfaces;
using PARR.Common.Domain;
using PARR.Constants;
using System.Text.Json;
@@ -21,18 +22,21 @@ namespace PARR.API.Controllers.V1
private readonly IMqService mqService;
private readonly IUriService uriService;
private readonly MqSettings mqSettings;
private readonly IClientService clientService;
public GeneratorTemplateController(
IValidator<GeneratorTemplateRequest> validator,
IMqService mqService,
IUriService uriService,
MqSettings mqSettings
MqSettings mqSettings,
IClientService clientService
)
{
this.validator = validator;
this.mqService = mqService;
this.uriService = uriService;
this.mqSettings = mqSettings;
this.clientService = clientService;
}
/// <summary>
@@ -60,7 +64,8 @@ namespace PARR.API.Controllers.V1
WorkId = request.WorkId,
StatusEk = status,
IsActiveTemplate = request.IsActiveTemplate,
IsActiveSchedule = request.IsActiveSchedule
IsActiveSchedule = request.IsActiveSchedule,
HistoryInitiator = new HistoryInitiator { InitiatorIp = clientService.GetClientIp()?.ToString(), InitiatorParrComponentId = ParrComponentsEnum.Api }
};
var msg = JsonSerializer.Serialize(obj);

View File

@@ -9,6 +9,7 @@ using PARR.API.Services.Interfaces;
using PARR.API.Settings;
using PARR.BLL.Domain.Mq;
using PARR.BLL.Services.Interfaces;
using PARR.Common.Domain;
using PARR.Constants;
using PARR.DAL.Services.Interfaces;
using System.Text.Json;
@@ -26,13 +27,15 @@ namespace PARR.API.Controllers.V1
private readonly IUriService uriService;
private readonly MqSettings mqSettings;
private readonly IApplicationsInWorkService applicationsInWorkService;
private readonly IClientService clientService;
public TemplateActivatorController(
IValidator<TemplateActivatorRequest> validator,
IMqService mqService,
IUriService uriService,
MqSettings mqSettings,
IApplicationsInWorkService applicationsInWorkService
IApplicationsInWorkService applicationsInWorkService,
IClientService clientService
)
{
this.validator = validator;
@@ -40,6 +43,7 @@ namespace PARR.API.Controllers.V1
this.uriService = uriService;
this.mqSettings = mqSettings;
this.applicationsInWorkService = applicationsInWorkService;
this.clientService = clientService;
}
@@ -64,7 +68,8 @@ namespace PARR.API.Controllers.V1
var mqRequest = new TemplateActivatorMq
{
ApplicationInWorkId = applicationInWorkId,
Action = request.Action
Action = request.Action,
HistoryInitiator = new HistoryInitiator { InitiatorIp = clientService.GetClientIp()?.ToString(), InitiatorParrComponentId = ParrComponentsEnum.Api }
};
var msg = JsonSerializer.Serialize(mqRequest);

View File

@@ -11,6 +11,7 @@ using PARR.API.Controllers.V1.Base;
using PARR.API.Extensions;
using PARR.API.Services.Interfaces;
using PARR.BLL.Helpers;
using PARR.Common.Domain;
using PARR.Constants;
using PARR.DAL.Contracts;
using PARR.DAL.DomainModels;
@@ -143,7 +144,7 @@ namespace PARR.API.Controllers.V1
robotConfigurationService.ChangeTaskStatus(TaskStatusEnum.Updating, ref config);
}
if (!await templateService.CommitAsync(new DAL.Models.Base.History.Base.HistoryInitiator { InitiatorComment = "Изменён статус шаблона/расписания", InitiatorIp = clientService.GetClientIp()?.ToString(), InitiatorParrComponentId = ParrComponentsEnum.Api }))
if (!await templateService.CommitAsync(new HistoryInitiator { InitiatorComment = "Изменён статус шаблона/расписания", InitiatorIp = clientService.GetClientIp()?.ToString(), InitiatorParrComponentId = ParrComponentsEnum.Api }))
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при изменении шаблона." } }));
var templateToResponse = await templateService.GetWithIncludes()