add: контроллер теплицы, добавлен сервис брокера в DI
This commit is contained in:
parent
1e2bd05667
commit
2a9508f737
79
Cloud/Controllers/GreengouseController.cs
Normal file
79
Cloud/Controllers/GreengouseController.cs
Normal file
@ -0,0 +1,79 @@
|
||||
using Cloud.Models;
|
||||
using Cloud.Requests;
|
||||
using Cloud.Services.Broker;
|
||||
using Cloud.Services.Broker.Support;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Cloud.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/user/{userId}/farm/{farmId}/greenhouse")]
|
||||
public class GreenhouseController : ControllerBase
|
||||
{
|
||||
private readonly IBrokerService _brokerService;
|
||||
private readonly ApplicationContext _context;
|
||||
private readonly IConfiguration _config;
|
||||
public GreenhouseController(IConfiguration config, ApplicationContext context,
|
||||
IBrokerService brokerService)
|
||||
{
|
||||
_brokerService = brokerService;
|
||||
_context = context;
|
||||
_config = config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает текущую информацию о всех теплицах пользователя
|
||||
*/
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<List<GreenhouseInfo>>> GetAll(int userId, int farmId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает текущую информацию о конкретной теплице
|
||||
*/
|
||||
[HttpGet("{greenhouseId}")]
|
||||
public async Task<ActionResult<GreenhouseInfo>> Get(int userId, int farmId, int greenhouseId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает сохраненные данные для автоматизации теплицы
|
||||
*/
|
||||
[HttpGet("{greenhouseId}/settings")]
|
||||
public async Task<ActionResult<Greenhouse>> GetGreenhouse(int userId, int farmId, int greenhouseId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Сохраняет в базе данных API данные для автоматизации теплицы
|
||||
*/
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<Greenhouse>> SaveToDatabase(int userId, int farmId, GreenhouseRequest greenhouse)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Обновляет в базе данных API данные для автоматизации теплицы
|
||||
*/
|
||||
[HttpPut("{greenhouseId}/settings")]
|
||||
public async Task<ActionResult<Greenhouse>> Update(int userId, int farmId, int greenhouseId, GreenhouseRequest greenhouse)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Удаляет из базы данных API запись настроек автоматизации теплицы
|
||||
*/
|
||||
[HttpDelete("{greenhouseId}")]
|
||||
public async Task<ActionResult> Delete(int userId, int farmId, int greenhouseId)
|
||||
{
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -7,11 +7,13 @@ using FluentValidation;
|
||||
using FluentValidation.AspNetCore;
|
||||
using Cloud.Validation;
|
||||
using StackExchange.Redis;
|
||||
using Cloud.Services.Broker.Implement.Kafka;
|
||||
using Cloud.Services.Broker;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddSingleton<IBrokerService, KafkaService>();
|
||||
//Redis configuration
|
||||
builder.Services.AddSingleton<IConnectionMultiplexer>(sp =>
|
||||
{
|
||||
|
11
Cloud/Requests/GreenhouseRequest.cs
Normal file
11
Cloud/Requests/GreenhouseRequest.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using Cloud.Models.Support;
|
||||
|
||||
namespace Cloud.Requests
|
||||
{
|
||||
public class GreenhouseRequest
|
||||
{
|
||||
public int RecomendedTemperature { get; set; }
|
||||
public WateringMode WateringMode { get; set; }
|
||||
public HeatingMode HeatingMode { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user