diff --git a/AsbCloudWebApi/Controllers/WellController.cs b/AsbCloudWebApi/Controllers/WellController.cs index 3bdf5819..d6d97547 100644 --- a/AsbCloudWebApi/Controllers/WellController.cs +++ b/AsbCloudWebApi/Controllers/WellController.cs @@ -1,13 +1,12 @@ using AsbCloudApp.Data; -using AsbCloudApp.Exceptions; using AsbCloudApp.Services; -using AsbCloudDb.Model; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Threading; using System.Threading.Tasks; +using AsbCloudApp.Services.WellReport; using Microsoft.AspNetCore.Http; namespace AsbCloudWebApi.Controllers; @@ -21,11 +20,13 @@ namespace AsbCloudWebApi.Controllers; public class WellController : ControllerBase { private readonly IWellService wellService; + private readonly IWellReportExportService wellReportExportService; - public WellController(IWellService wellService) - { - this.wellService = wellService; - } + public WellController(IWellService wellService, IWellReportExportService wellReportExportService) + { + this.wellService = wellService; + this.wellReportExportService = wellReportExportService; + } /// /// Возвращает список доступных скважин @@ -151,16 +152,24 @@ public class WellController : ControllerBase } + //TODO: навзание пока такое. У нас в API уже есть метод с такой сигнатурой. + /// /// Получить отчёт по скважине /// /// /// /// - [HttpGet("{idWell}/report")] - [ProducesResponseType(typeof(PhysicalFileResult), StatusCodes.Status200OK)] - public Task GetReportAsync(int idWell, CancellationToken token) + [HttpGet("{idWell}/report/export")] + [ProducesResponseType(typeof(PhysicalFileResult), StatusCodes.Status200OK, "application/octet-stream")] + [ProducesResponseType(StatusCodes.Status204NoContent)] + public async Task ExportAsync(int idWell, CancellationToken token) { + var report = await wellReportExportService.ExportAsync(idWell, token); + if (report is null) + return NoContent(); + + return File(report.Value.File, "application/octet-stream", report.Value.Name); } }