From e7fea108adf079dcb22a76880a676bd3e459b3b7 Mon Sep 17 00:00:00 2001 From: Mikhail Trubnikov Date: Thu, 11 Jan 2024 10:46:38 +1000 Subject: [PATCH] =?UTF-8?q?feat(api):=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20host=20=D0=BF=D0=BE=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PARR.API/Contracts/V1/ApiRoutes.cs | 3 +++ PARR.API/Controllers/V1/HostController.cs | 25 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/PARR.API/Contracts/V1/ApiRoutes.cs b/PARR.API/Contracts/V1/ApiRoutes.cs index 7bf956f9..7059c593 100644 --- a/PARR.API/Contracts/V1/ApiRoutes.cs +++ b/PARR.API/Contracts/V1/ApiRoutes.cs @@ -99,6 +99,9 @@ namespace PARR.API.Contracts.V1 public static class Host { public const string GetAll = Base + "/hosts/"; + public const string Get = Base + "/hosts/" + getParam; + + public const string getParam = "{id}"; } public static class RobotHistoryLevel diff --git a/PARR.API/Controllers/V1/HostController.cs b/PARR.API/Controllers/V1/HostController.cs index 56ed8674..48434051 100644 --- a/PARR.API/Controllers/V1/HostController.cs +++ b/PARR.API/Controllers/V1/HostController.cs @@ -57,5 +57,30 @@ namespace PARR.API.Controllers.V1 return Ok(paginationResponse); } + + + /// + /// Получить хост по id + /// + /// + /// + [HttpGet(ApiRoutes.Host.Get)] + public async Task 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(host); + + return Ok(new Response(response, true)); + } + + } }