persistence/Persistence.API/Controllers/TimeSeriesController.cs

49 lines
1.5 KiB
C#
Raw Normal View History

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Persistence.Models;
using Persistence.Repositories;
namespace Persistence.API.Controllers;
[ApiController]
[Authorize]
[Route("api/[controller]")]
public class TimeSeriesController<TDto> : ControllerBase, ITimeSeriesDataApi<TDto>
where TDto : class, ITimeSeriesAbstractDto, new()
{
private ITimeSeriesDataRepository<TDto> timeSeriesDataRepository;
public TimeSeriesController(ITimeSeriesDataRepository<TDto> timeSeriesDataRepository)
{
this.timeSeriesDataRepository = timeSeriesDataRepository;
}
[HttpGet]
[ProducesResponseType(StatusCodes.Status200OK)]
2024-11-21 17:02:36 +05:00
public async Task<IActionResult> Get(DateTimeOffset dateBegin, CancellationToken token)
{
2024-11-21 17:02:36 +05:00
var result = await this.timeSeriesDataRepository.GetGtDate(dateBegin, token);
return Ok(result);
}
[HttpGet("datesRange")]
2024-11-21 17:02:36 +05:00
public async Task<IActionResult> GetDatesRange(CancellationToken token)
{
2024-11-21 17:02:36 +05:00
var result = await this.timeSeriesDataRepository.GetDatesRange(token);
return Ok(result);
}
2024-11-21 17:02:36 +05:00
public Task<IActionResult> GetResampledData(DateTimeOffset dateBegin, DateTimeOffset dateEnd, int approxPointsCount = 1024)
{
throw new NotImplementedException();
}
[HttpPost]
2024-11-21 17:02:36 +05:00
public async Task<IActionResult> InsertRange(IEnumerable<TDto> dtos, CancellationToken token)
{
var result = await this.timeSeriesDataRepository.InsertRange(dtos, token);
return Ok(result);
}
2024-11-21 17:02:36 +05:00
}