feat(api): Контроллер управления историей робота. Контролпер по получению списка уровней истории робота

This commit is contained in:
Mikhail Trubnikov
2023-10-04 15:22:06 +10:00
parent 3e67c96ed1
commit f435f80636
10 changed files with 258 additions and 29 deletions

View File

@@ -0,0 +1,42 @@
using AutoMapper;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using PARR.API.Contracts.V1;
using PARR.API.Contracts.V1.Responses;
using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using PARR.DAL.Services.Interfaces;
namespace PARR.API.Controllers.V1
{
public class RobotHistoryLevelController : BaseApiController
{
private readonly IMapper mapper;
private readonly IRobotHistoryLevelService robotHistoryLevelService;
public RobotHistoryLevelController(
IMapper mapper,
IRobotHistoryLevelService robotHistoryLevelService
)
{
this.mapper = mapper;
this.robotHistoryLevelService = robotHistoryLevelService;
}
/// <summary>
/// Получить список уровней истории работы робота
/// </summary>
/// <returns></returns>
[HttpGet(ApiRoutes.RobotHistoryLevel.GetAll)]
public async Task<IActionResult> GetAll()
{
var levels = await robotHistoryLevelService.Get()
.OrderBy(t => t.Level)
.ToListAsync();
var response = mapper.Map<List<RobotHistoryLevelResponse>>(levels);
return Ok(new Response<List<RobotHistoryLevelResponse>>(response, true));
}
}
}