From f0aefbc2a1cbf7c1400a6836157d2835e385dd29 Mon Sep 17 00:00:00 2001 From: Mikhail Trubnikov Date: Mon, 16 Mar 2026 16:11:41 +1000 Subject: [PATCH] =?UTF-8?q?feat(api):=20TestController=20-=20=D1=80=D0=B0?= =?UTF-8?q?=D1=81=D1=81=D1=87=D0=B8=D1=82=D0=B0=D1=82=D1=8C=20nextRun?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PARR.API/Contracts/V1/ApiRoutes.cs | 2 ++ PARR.API/Controllers/V1/TestController.cs | 32 +++++++++++++++++------ 2 files changed, 26 insertions(+), 8 deletions(-) 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)); + } + + ///// ///// Получить следующую дату запуска /////