using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using ZeroFramework.DeviceCenter.Application.Models.Measurements; using ZeroFramework.DeviceCenter.Application.PermissionProviders; using ZeroFramework.DeviceCenter.Application.Services.Generics; using ZeroFramework.DeviceCenter.Application.Services.Measurements; namespace ZeroFramework.DeviceCenter.API.Controllers { [Route("api/[controller]")] [ApiController] public class MeasurementsController(IDeviceDataApplicationService deviceDataApplication) : ControllerBase { private readonly IDeviceDataApplicationService _deviceDataApplication = deviceDataApplication; [HttpGet("property-values")] [Authorize(MeasurementPermissions.Measurements.DevicePropertyValues)] public async Task?> GetDevicePropertyValues(int productId, long deviceId) { return await _deviceDataApplication.GetDevicePropertyValues(productId, deviceId); } [HttpGet("property-history-values")] [Authorize(MeasurementPermissions.Measurements.DevicePropertyHistoryValues)] public async Task?> GetDevicePropertyHistoryValues(int productId, long deviceId, string identifier, DateTimeOffset startTime, DateTimeOffset endTime, SortingOrder sorting, int pageNumber, int pageSize) { int offset = (pageNumber - 1) * pageSize; return await _deviceDataApplication.GetDevicePropertyHistoryValues(productId, deviceId, identifier, startTime, endTime, false, sorting, offset, pageSize); } [HttpGet("property-reports")] [Authorize(MeasurementPermissions.Measurements.DevicePropertyReports)] public async Task?> GetDevicePropertyReports(int productId, long deviceId, string identifier, DateTimeOffset startTime, DateTimeOffset endTime, string reportType, int pageNumber, int pageSize) { int offset = (pageNumber - 1) * pageSize; return await _deviceDataApplication.GetDevicePropertyReports(productId, deviceId, identifier, startTime, endTime, reportType, offset, pageSize); } [HttpPut("property-values")] [Authorize(MeasurementPermissions.Measurements.SetDevicePropertyValues)] public async Task SetDevicePropertyValue([FromQuery] int productId, [FromQuery] long deviceId, [FromBody] IDictionary values) { await _deviceDataApplication.SetDevicePropertyValues(productId, deviceId, values); } } }