feat(dal): BaseService - доделал ведение истории

This commit is contained in:
Mikhail Trubnikov
2024-10-08 09:40:08 +10:00
parent a0e71c9948
commit 54fed9b597
2 changed files with 15 additions and 18 deletions

View File

@@ -9,6 +9,7 @@ using PARR.API.Contracts.V1.Responses;
using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using PARR.API.Extensions;
using PARR.API.Services.Interfaces;
using PARR.BLL.Helpers;
using PARR.Constants;
using PARR.DAL.Contracts;
@@ -28,18 +29,21 @@ namespace PARR.API.Controllers.V1
private readonly ITemplateService templateService;
private readonly SettingsFromDb settingsFromDb;
private readonly IRobotConfigurationService robotConfigurationService;
private readonly IClientService clientService;
public TemplateController(
IMapper mapper,
ITemplateService templateService,
SettingsFromDb settingsFromDb,
IRobotConfigurationService robotConfigurationService
IRobotConfigurationService robotConfigurationService,
IClientService clientService
)
{
this.mapper = mapper;
this.templateService = templateService;
this.settingsFromDb = settingsFromDb;
this.robotConfigurationService = robotConfigurationService;
this.clientService = clientService;
}
@@ -91,7 +95,7 @@ namespace PARR.API.Controllers.V1
.Include(t => t.RobotConfigurations).ThenInclude(t => t.Robot)
.Include(t => t.RobotConfigurations).ThenInclude(t => t.TaskStatus)
.Include(t => t.RobotConfigurations).ThenInclude(t => t.RobotStatus)
.Include(t=>t.Orders)
.Include(t => t.Orders)
.AsSplitQuery()
.FirstOrDefaultAsync(t => t.Id == id);
@@ -139,7 +143,7 @@ namespace PARR.API.Controllers.V1
robotConfigurationService.ChangeTaskStatus(TaskStatusEnum.Updating, ref config);
}
if (!await templateService.CommitAsync())
if (!await templateService.CommitAsync(new DAL.Models.Base.History.Base.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()