feat(api): получение host по id
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user