forked from ddrilling/AsbCloudServer
Добавлен метод API экспорта отчёта по скважине
This commit is contained in:
parent
307c29fcfd
commit
e2f053af6c
@ -1,13 +1,12 @@
|
|||||||
using AsbCloudApp.Data;
|
using AsbCloudApp.Data;
|
||||||
using AsbCloudApp.Exceptions;
|
|
||||||
using AsbCloudApp.Services;
|
using AsbCloudApp.Services;
|
||||||
using AsbCloudDb.Model;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using AsbCloudApp.Services.WellReport;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace AsbCloudWebApi.Controllers;
|
namespace AsbCloudWebApi.Controllers;
|
||||||
@ -21,11 +20,13 @@ namespace AsbCloudWebApi.Controllers;
|
|||||||
public class WellController : ControllerBase
|
public class WellController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IWellService wellService;
|
private readonly IWellService wellService;
|
||||||
|
private readonly IWellReportExportService wellReportExportService;
|
||||||
|
|
||||||
public WellController(IWellService wellService)
|
public WellController(IWellService wellService, IWellReportExportService wellReportExportService)
|
||||||
{
|
{
|
||||||
this.wellService = wellService;
|
this.wellService = wellService;
|
||||||
}
|
this.wellReportExportService = wellReportExportService;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Возвращает список доступных скважин
|
/// Возвращает список доступных скважин
|
||||||
@ -151,16 +152,24 @@ public class WellController : ControllerBase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: навзание пока такое. У нас в API уже есть метод с такой сигнатурой.
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Получить отчёт по скважине
|
/// Получить отчёт по скважине
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="idWell"></param>
|
/// <param name="idWell"></param>
|
||||||
/// <param name="token"></param>
|
/// <param name="token"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet("{idWell}/report")]
|
[HttpGet("{idWell}/report/export")]
|
||||||
[ProducesResponseType(typeof(PhysicalFileResult), StatusCodes.Status200OK)]
|
[ProducesResponseType(typeof(PhysicalFileResult), StatusCodes.Status200OK, "application/octet-stream")]
|
||||||
public Task<IActionResult> GetReportAsync(int idWell, CancellationToken token)
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
public async Task<IActionResult> 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user