2023-08-24 17:03:12 +10:00
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
|
|
|
|
|
using PARR.API.Contracts.V1;
|
2023-08-25 10:25:24 +10:00
|
|
|
|
using PARR.API.Contracts.V1.Responses.Base;
|
2023-08-24 17:03:12 +10:00
|
|
|
|
using PARR.API.Controllers.V1.Base;
|
2023-08-25 10:25:24 +10:00
|
|
|
|
using PARR.BLL.Services.Interfaces;
|
|
|
|
|
|
using PARR.BLL.Settings;
|
2023-08-24 17:03:12 +10:00
|
|
|
|
|
|
|
|
|
|
namespace PARR.API.Controllers.V1
|
|
|
|
|
|
{
|
|
|
|
|
|
public class EsppDataController : BaseApiController
|
|
|
|
|
|
{
|
2023-09-15 16:32:46 +10:00
|
|
|
|
private readonly ILogger<EsppDataController> logger;
|
2023-08-24 17:03:12 +10:00
|
|
|
|
private readonly IFileService fileService;
|
2023-08-25 10:25:24 +10:00
|
|
|
|
private readonly StorageSettings storageSettings;
|
2023-08-24 17:03:12 +10:00
|
|
|
|
|
2023-08-25 10:25:24 +10:00
|
|
|
|
public EsppDataController(
|
|
|
|
|
|
ILogger<EsppDataController> logger,
|
|
|
|
|
|
IFileService fileService,
|
|
|
|
|
|
StorageSettings storageSettings
|
|
|
|
|
|
)
|
2023-08-24 17:03:12 +10:00
|
|
|
|
{
|
2023-09-15 16:32:46 +10:00
|
|
|
|
this.logger = logger;
|
2023-08-24 17:03:12 +10:00
|
|
|
|
this.fileService = fileService;
|
2023-08-25 10:25:24 +10:00
|
|
|
|
this.storageSettings = storageSettings;
|
2023-08-24 17:03:12 +10:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-09-15 16:32:46 +10:00
|
|
|
|
// UploadTemplates - неактуально, так как стали брать данные с RabbitMQ
|
2023-08-24 17:03:12 +10:00
|
|
|
|
|
2023-09-15 16:32:46 +10:00
|
|
|
|
///// <summary>
|
|
|
|
|
|
///// Загрузить файл списка шаблонов полученных из ЕСПП в формате csv
|
|
|
|
|
|
///// </summary>
|
|
|
|
|
|
///// <returns></returns>
|
|
|
|
|
|
//[HttpPost(ApiRoutes.EsppData.UploadTemplates)]
|
|
|
|
|
|
//public async Task<IActionResult> UploadTemplates([BindRequired] IFormFile file)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// if (!fileService.IsExtensionAllowed(file, storageSettings.EsppTemplates!.AllowedExtensions))
|
|
|
|
|
|
// return BadRequest(
|
|
|
|
|
|
// new Response(false,
|
|
|
|
|
|
// new List<ErrorModel> {
|
|
|
|
|
|
// new ErrorModel {
|
|
|
|
|
|
// Message = $"Недопустимое расширение файла. Разрешенные расширения: {string.Join(", ", storageSettings.EsppTemplates.AllowedExtensions)}"
|
|
|
|
|
|
// } }));
|
2023-08-25 10:25:24 +10:00
|
|
|
|
|
2023-09-15 16:32:46 +10:00
|
|
|
|
// if (!fileService.IsNotExceededLimit(file, storageSettings.EsppTemplates.MaxFileSizeMb))
|
|
|
|
|
|
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { FieldName = nameof(file), Message = $"Размер файла превышает {storageSettings.EsppTemplates.MaxFileSizeMb} МБайт" } }));
|
2023-08-25 10:25:24 +10:00
|
|
|
|
|
2023-09-15 16:32:46 +10:00
|
|
|
|
// var uploadResult = await fileService.UploadAsync(file, storageSettings.EsppTemplates.TemplatePath);
|
|
|
|
|
|
// if (uploadResult == null)
|
|
|
|
|
|
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Ошибка при сохранении файла" } }));
|
2023-08-25 10:25:24 +10:00
|
|
|
|
|
2023-09-15 16:32:46 +10:00
|
|
|
|
// return Ok(new Response<string>("", true, new List<ErrorModel>(), $"Файл загружен."));
|
|
|
|
|
|
//}
|
2023-08-24 17:03:12 +10:00
|
|
|
|
}
|
|
|
|
|
|
}
|