using Cloud.Requests; using Cloud.Services.Broker; using Cloud.Services.Broker.Implement.Kafka; using Cloud.Services.Broker.Support; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Cloud.Controllers { [Authorize] [ApiController] [Route("api")] public class HeaterController : Controller { //Контроллер вентиля private readonly IBrokerService _kafkaService; public HeaterController(KafkaService kafkaService) { _kafkaService = kafkaService; } [HttpPost("farm/{farmId}/greenhouse/{ghId}/heating")] public async Task interactValve([FromBody] HeaterRequest request, int farmId, int ghId) { var command = new Command { request_id = Guid.NewGuid(), greenhouse_id = ghId, farm_id = farmId, command = "heater", target_temp = request.Temperature }; await _kafkaService.ProduceAsync("commands", command); return Ok($"Heater target temperature is set as {request.Temperature}"); } } }