feat(api): получение host по id

This commit is contained in:
Mikhail Trubnikov
2024-01-11 10:46:38 +10:00
parent 48bdf9f38f
commit e7fea108ad
2 changed files with 28 additions and 0 deletions

View File

@@ -99,6 +99,9 @@ namespace PARR.API.Contracts.V1
public static class Host public static class Host
{ {
public const string GetAll = Base + "/hosts/"; public const string GetAll = Base + "/hosts/";
public const string Get = Base + "/hosts/" + getParam;
public const string getParam = "{id}";
} }
public static class RobotHistoryLevel public static class RobotHistoryLevel

View File

@@ -57,5 +57,30 @@ namespace PARR.API.Controllers.V1
return Ok(paginationResponse); return Ok(paginationResponse);
} }
/// <summary>
/// Получить хост по id
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet(ApiRoutes.Host.Get)]
public async Task<IActionResult> GetById([FromRoute] Guid id)
{
var host = await hostService.Get()
.Include(s => s.EkStatus)
.Include(s => s.ResponseArea)
.Include(t => t.ApplicationsInHosts).ThenInclude(t => t.Application).ThenInclude(t => t!.ApplicationType)
.FirstOrDefaultAsync(t => t.Id == id);
if (host == null)
return NotFound();
var response = mapper.Map<HostWithApplicationsResponse>(host);
return Ok(new Response<HostWithApplicationsResponse>(response, true));
}
} }
} }