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 SetpointController : ControllerBase, ISetpointApi { private readonly ISetpointRepository setpointRepository; public SetpointController(ISetpointRepository setpointRepository) { this.setpointRepository = setpointRepository; } [HttpGet("current")] public async Task>> GetCurrent([FromQuery] IEnumerable setpointKeys, CancellationToken token) { var result = await setpointRepository.GetCurrent(setpointKeys, token); return Ok(result); } [HttpGet("history")] public async Task>> GetHistory([FromQuery] IEnumerable setpointKeys, [FromQuery] DateTimeOffset historyMoment, CancellationToken token) { var result = await setpointRepository.GetHistory(setpointKeys, historyMoment, token); return Ok(result); } [HttpGet("log")] public async Task>>> GetLog([FromQuery] IEnumerable setpointKeys, CancellationToken token) { var result = await setpointRepository.GetLog(setpointKeys, token); return Ok(result); } [HttpPost] public async Task> Save(Guid setpointKey, object newValue, CancellationToken token) { // ToDo: вычитка idUser await setpointRepository.Save(setpointKey, newValue, 0, token); return Ok(); } } }