diff --git a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapBaseController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapBaseController.cs index 6dc1d7d6..9fe84901 100644 --- a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapBaseController.cs +++ b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapBaseController.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading; using System.Threading.Tasks; using AsbCloudApp.Data; @@ -8,6 +9,7 @@ using AsbCloudApp.Exceptions; using AsbCloudApp.Repositories; using AsbCloudApp.Requests; using AsbCloudApp.Services; +using AsbCloudApp.Services.ProcessMaps; using AsbCloudWebApi.SignalR; using AsbCloudWebApi.SignalR.Clients; using Microsoft.AspNetCore.Authorization; @@ -32,13 +34,15 @@ public abstract class ProcessMapBaseController : ControllerBase private readonly IUserRepository userRepository; private readonly ICrudRepository wellSectionRepository; private readonly IProcessMapPlanRepository repository; - + private readonly IProcessMapPlanService service; + protected ProcessMapBaseController(IWellService wellService, IProcessMapPlanRepository repository, IUserRepository userRepository, ICrudRepository wellSectionRepository, IHubContext telemetryHubContext, - ITelemetryService telemetryService) + ITelemetryService telemetryService, + IProcessMapPlanService service) { this.wellService = wellService; this.repository = repository; @@ -46,9 +50,10 @@ public abstract class ProcessMapBaseController : ControllerBase this.wellSectionRepository = wellSectionRepository; this.telemetryHubContext = telemetryHubContext; this.telemetryService = telemetryService; + this.service = service; } - public abstract string SignalRMethod { get; } + protected abstract string SignalRGroup { get; } protected int IdUser { @@ -147,10 +152,16 @@ public abstract class ProcessMapBaseController : ControllerBase /// /// [HttpGet] - public async Task>> GetAsync(int idWell, CancellationToken cancellationToken) + [ProducesResponseType(typeof(ValidationResultDto<>), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status204NoContent)] + [ProducesResponseType(StatusCodes.Status403Forbidden)] + public async Task>> GetAsync(int idWell, CancellationToken cancellationToken) { - var processMaps = await repository.GetByIdWellAsync(idWell, cancellationToken); + var processMaps = await service.GetAsync(idWell, cancellationToken); + if (!processMaps.Any()) + return NoContent(); + return Ok(processMaps); } @@ -204,7 +215,7 @@ public abstract class ProcessMapBaseController : ControllerBase var dtos = await repository.GetByIdWellAsync(idWell, cancellationToken); await telemetryHubContext.Clients - .Group($"{SignalRMethod}_{idWell}") + .Group($"{SignalRGroup}_{idWell}") .UpdateProcessMap(dtos, cancellationToken); } diff --git a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellDrillingController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellDrillingController.cs index 9f6812e6..538303a8 100644 --- a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellDrillingController.cs +++ b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellDrillingController.cs @@ -26,7 +26,7 @@ public class ProcessMapWellDrillingController : ProcessMapBaseController "ProcessMapWellDrilling"; + protected override string SignalRGroup => "ProcessMapWellDrilling"; public ProcessMapWellDrillingController(IWellService wellService, IProcessMapPlanRepository repository, @@ -36,8 +36,9 @@ public class ProcessMapWellDrillingController : ProcessMapBaseController wellSectionRepository, IHubContext telemetryHubContext, - ITelemetryService telemetryService) - : base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService) + ITelemetryService telemetryService, + IProcessMapPlanService service) + : base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService, service) { this.processMapReportWellDrillingExportService = processMapReportWellDrillingExportService; this.processMapPlanImportService = processMapPlanImportService; diff --git a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellReamController.cs b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellReamController.cs index b54323d2..b9c5ea94 100644 --- a/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellReamController.cs +++ b/AsbCloudWebApi/Controllers/ProcessMaps/ProcessMapWellReamController.cs @@ -2,6 +2,7 @@ using AsbCloudApp.Data.ProcessMaps; using AsbCloudApp.Repositories; using AsbCloudApp.Services; +using AsbCloudApp.Services.ProcessMaps; using AsbCloudWebApi.SignalR; using AsbCloudWebApi.SignalR.Clients; using Microsoft.AspNetCore.SignalR; @@ -13,15 +14,16 @@ namespace AsbCloudWebApi.Controllers.ProcessMaps; /// public class ProcessMapWellReamController : ProcessMapBaseController { - public ProcessMapWellReamController(IWellService wellService, - IProcessMapPlanRepository repository, - IUserRepository userRepository, - ICrudRepository wellSectionRepository, - IHubContext telemetryHubContext, - ITelemetryService telemetryService) - : base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService) - { - } + public ProcessMapWellReamController(IWellService wellService, + IProcessMapPlanRepository repository, + IUserRepository userRepository, + ICrudRepository wellSectionRepository, + IHubContext telemetryHubContext, + ITelemetryService telemetryService, + IProcessMapPlanService service) + : base(wellService, repository, userRepository, wellSectionRepository, telemetryHubContext, telemetryService, service) + { + } - public override string SignalRMethod => "ProccessMapWellReam"; + protected override string SignalRGroup => "ProcessMapWellReam"; } \ No newline at end of file