diff --git a/PARR.API/Contracts/V1/ApiRoutes.cs b/PARR.API/Contracts/V1/ApiRoutes.cs index 48f6eae3..ecb11262 100644 --- a/PARR.API/Contracts/V1/ApiRoutes.cs +++ b/PARR.API/Contracts/V1/ApiRoutes.cs @@ -47,6 +47,8 @@ { public const string GetMyIp = Base + "/tests/my-ip"; + public const string GetNextRun = Base + "/tests/next-run"; + public const string GetNextScheduleDate = Base + "/tests/next-schedule-date/" + paramApplicationInWorkId + "/" + paramDate; public const string GetNextSchedule = Base + "/tests/next-schedule/" + paramApplicationInWorkId + "/" + paramDate; diff --git a/PARR.API/Controllers/V1/TestController.cs b/PARR.API/Controllers/V1/TestController.cs index 5c8f360b..da19f183 100644 --- a/PARR.API/Controllers/V1/TestController.cs +++ b/PARR.API/Controllers/V1/TestController.cs @@ -1,19 +1,13 @@ using AutoMapper; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; using PARR.API.Contracts.V1; -using PARR.API.Contracts.V1.Requests.Queries; -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.DAL.Cache.Services.Base; -using PARR.DAL.Contracts; -using PARR.DAL.DomainModels; using PARR.DAL.DomainServices.UnitFilterService; -using PARR.DAL.Models.Job; +using PARR.DAL.NextRunServices; using PARR.DAL.Services.Interfaces; using PARR.DAL.Services.Interfaces.Job; using PARR.DAL.Services.Interfaces.Unit; @@ -34,6 +28,8 @@ namespace PARR.API.Controllers.V1 private readonly IJobUnitFilterService jobUnitFilterService; private readonly IUnitFilterService unitFilterService; private readonly IMapper mapper; + private readonly INextRunService nextRunService; + private readonly ITemplateService templateService; public TestController( IClientService clientService, @@ -45,7 +41,9 @@ namespace PARR.API.Controllers.V1 IJobService jobService, IJobUnitFilterService jobUnitFilterService, IUnitFilterService unitFilterService, - IMapper mapper + IMapper mapper, + INextRunService nextRunService, + ITemplateService templateService ) { this.clientService = clientService; @@ -58,6 +56,8 @@ namespace PARR.API.Controllers.V1 this.jobUnitFilterService = jobUnitFilterService; this.unitFilterService = unitFilterService; this.mapper = mapper; + this.nextRunService = nextRunService; + this.templateService = templateService; } @@ -76,6 +76,22 @@ namespace PARR.API.Controllers.V1 } + public record GetNextRunRequest(Guid TemplateId, bool IsNew); + + /// + /// Получить nextRun + /// + /// + [HttpPost(ApiRoutes.Test.GetNextRun)] + public async Task GetNextRun([FromBody] GetNextRunRequest request) + { + var nextRun = await nextRunService.GetNextRunForTemplateAsync(request.TemplateId, request.IsNew); + var template = await templateService.GetAsync(request.TemplateId); + + return Ok(new Response(new { OldNextRun = template?.NextRun, NewNextRun = nextRun }, true)); + } + + ///// ///// Получить следующую дату запуска /////