From e2f053af6c857c39d159e581cc3cc73952fcf664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=82=D0=B5=D0=BF=D0=B0=D0=BD=D0=BE=D0=B2=20=D0=94?= =?UTF-8?q?=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Mon, 2 Sep 2024 10:16:04 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=20API=20=D1=8D=D0=BA?= =?UTF-8?q?=D1=81=D0=BF=D0=BE=D1=80=D1=82=D0=B0=20=D0=BE=D1=82=D1=87=D1=91?= =?UTF-8?q?=D1=82=D0=B0=20=D0=BF=D0=BE=20=D1=81=D0=BA=D0=B2=D0=B0=D0=B6?= =?UTF-8?q?=D0=B8=D0=BD=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AsbCloudWebApi/Controllers/WellController.cs | 27 +++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) 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); } }