From 9cc166e37d53639b6c68de330dbb8ac6dcbf3161 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0=20=D0=97=D0=B5=D0=BB?= =?UTF-8?q?=D1=82=D1=8B=D0=BD=D1=8C?= Date: Sun, 31 May 2026 01:27:28 +0900 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B4=D0=B5=D0=BB=D1=8C=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B?= =?UTF-8?q?=D1=85=20=D0=B4=D0=BB=D1=8F=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BF=D1=80=D0=B8=D0=BD=D0=B5=D1=80=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Location/ILocationService.cs | 7 +++++++ .../Location/LocationController.cs | 20 +++++++++++++++++++ .../Controllers/Location/LocationMap.cs | 12 +++++++++++ .../Controllers/Location/LocationService.cs | 10 ++++++++++ CartriX.Api/Controllers/Printer/PrinterMap.cs | 9 +++++++++ CartriX.Api/Entities/Printer.cs | 2 +- CartriX.Api/Entities/PrinterModel.cs | 4 ++++ CartriX.Api/Program.cs | 2 ++ .../Models/Location/LocationItem.cs | 8 ++++++++ .../Models/Printer/PrinterItemList.cs | 10 ++++++++++ .../Models/Printer/PrinterModelItem.cs | 4 ++++ 11 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 CartriX.Api/Controllers/Location/ILocationService.cs create mode 100644 CartriX.Api/Controllers/Location/LocationController.cs create mode 100644 CartriX.Api/Controllers/Location/LocationMap.cs create mode 100644 CartriX.Api/Controllers/Location/LocationService.cs create mode 100644 CartriX.Shared/Models/Location/LocationItem.cs create mode 100644 CartriX.Shared/Models/Printer/PrinterItemList.cs diff --git a/CartriX.Api/Controllers/Location/ILocationService.cs b/CartriX.Api/Controllers/Location/ILocationService.cs new file mode 100644 index 0000000..328542e --- /dev/null +++ b/CartriX.Api/Controllers/Location/ILocationService.cs @@ -0,0 +1,7 @@ +namespace CartriX.Api.Controllers.Location +{ + public interface ILocationService + { + public Task> List(); + } +} diff --git a/CartriX.Api/Controllers/Location/LocationController.cs b/CartriX.Api/Controllers/Location/LocationController.cs new file mode 100644 index 0000000..2635f81 --- /dev/null +++ b/CartriX.Api/Controllers/Location/LocationController.cs @@ -0,0 +1,20 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace CartriX.Api.Controllers.Location +{ + [Route("api/[controller]")] + [ApiController] + public class LocationController(ILocationService _locationService) : ControllerBase + { + /// + /// Получить список местоположений + /// + [ProducesResponseType(typeof(List), StatusCodes.Status200OK)] + [HttpGet(nameof(List))] + public async Task List() + { + return Ok((await _locationService.List()).Select(l => l.ToItem())); + } + } +} diff --git a/CartriX.Api/Controllers/Location/LocationMap.cs b/CartriX.Api/Controllers/Location/LocationMap.cs new file mode 100644 index 0000000..47d2a1f --- /dev/null +++ b/CartriX.Api/Controllers/Location/LocationMap.cs @@ -0,0 +1,12 @@ +using CartriX.Api.Controllers.Cartridge; +namespace CartriX.Api.Controllers.Location +{ + public static class LocationMap + { + public static Shared.Models.Location.LocationItem ToItem(this Entities.Location location) => new() + { + Name = location.Name, + Printers = location.Printers.Select(p => p.ToItem()).ToList() + }; + } +} diff --git a/CartriX.Api/Controllers/Location/LocationService.cs b/CartriX.Api/Controllers/Location/LocationService.cs new file mode 100644 index 0000000..7cc3070 --- /dev/null +++ b/CartriX.Api/Controllers/Location/LocationService.cs @@ -0,0 +1,10 @@ +using CartriX.Shared.Models.Location; +using Microsoft.EntityFrameworkCore; + +namespace CartriX.Api.Controllers.Location +{ + public class LocationService(AppDbContext _context) : ILocationService + { + public async Task> List() => await _context.Locations.ToListAsync(); + } +} diff --git a/CartriX.Api/Controllers/Printer/PrinterMap.cs b/CartriX.Api/Controllers/Printer/PrinterMap.cs index 357e665..6a93825 100644 --- a/CartriX.Api/Controllers/Printer/PrinterMap.cs +++ b/CartriX.Api/Controllers/Printer/PrinterMap.cs @@ -22,6 +22,15 @@ namespace CartriX.Api.Controllers.Cartridge Name = model.Name, Manufacturer = model.Manufacturer.ToItem(), }; + public static Shared.Models.Printer.PrinterItemList ToItemList(this Entities.Printer printer) => new() + { + Name = printer.Name, + Model = printer.Model.ToItem(), + StatusId = printer.Status.Name, + ConnetctionTypeName = printer.ConnetctionType.Name, + InstalledCartridgeId = printer.InstalledCartridge.Id, + LocationName = printer.Location.Name, + }; } } diff --git a/CartriX.Api/Entities/Printer.cs b/CartriX.Api/Entities/Printer.cs index df14f69..0c1da6a 100644 --- a/CartriX.Api/Entities/Printer.cs +++ b/CartriX.Api/Entities/Printer.cs @@ -43,7 +43,7 @@ namespace CartriX.Api.Entities /// /// Идентификатор printerStatus /// - public required int PrinterStatusId { get; set; } + public required int StatusId { get; set; } /// /// Статус принтера /// diff --git a/CartriX.Api/Entities/PrinterModel.cs b/CartriX.Api/Entities/PrinterModel.cs index 51ee6b9..e332176 100644 --- a/CartriX.Api/Entities/PrinterModel.cs +++ b/CartriX.Api/Entities/PrinterModel.cs @@ -15,6 +15,10 @@ /// public required Manufacturer Manufacturer { get; set; } /// + /// Путь к картинке + /// + public string? PicturePath { get; set; } + /// /// Идентификатор поддерживамого артикля /// public int SupportedArticleId { get; set; } diff --git a/CartriX.Api/Program.cs b/CartriX.Api/Program.cs index 98686f6..4a247fe 100644 --- a/CartriX.Api/Program.cs +++ b/CartriX.Api/Program.cs @@ -4,6 +4,7 @@ using Newtonsoft.Json.Serialization; using CartriX.Api; using CartriX.Api.Controllers.Cartridge; using CartriX.Api.Controllers.Report; +using CartriX.Api.Controllers.Location; var builder = WebApplication.CreateBuilder(args); @@ -13,6 +14,7 @@ builder.Services.AddControllers().AddNewtonsoftJson(options => }); builder.Services.AddScoped(); +builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); diff --git a/CartriX.Shared/Models/Location/LocationItem.cs b/CartriX.Shared/Models/Location/LocationItem.cs new file mode 100644 index 0000000..02844e1 --- /dev/null +++ b/CartriX.Shared/Models/Location/LocationItem.cs @@ -0,0 +1,8 @@ +namespace CartriX.Shared.Models.Location +{ + public class LocationItem + { + public string Name { get; set; } = default!; + public List Printers { get; set; } = default!; + } +} diff --git a/CartriX.Shared/Models/Printer/PrinterItemList.cs b/CartriX.Shared/Models/Printer/PrinterItemList.cs new file mode 100644 index 0000000..ad4b09e --- /dev/null +++ b/CartriX.Shared/Models/Printer/PrinterItemList.cs @@ -0,0 +1,10 @@ +namespace CartriX.Shared.Models.Printer +{ + public class PrinterItemList + { + public int Id { get; set; } + public string Name { get; set; } = string.Empty; + public PrinterModelItem Model { get; set; } = default!; + public int StatusId { get; set; } + } +} diff --git a/CartriX.Shared/Models/Printer/PrinterModelItem.cs b/CartriX.Shared/Models/Printer/PrinterModelItem.cs index 1e6b9f5..3aba893 100644 --- a/CartriX.Shared/Models/Printer/PrinterModelItem.cs +++ b/CartriX.Shared/Models/Printer/PrinterModelItem.cs @@ -11,6 +11,10 @@ /// public ManufacturerItem Manufacturer { get; set; } = new(); /// + /// Путь к картинке + /// + public string? PicturePath { get; set; } + /// /// Идентификатор поддерживамого артикля /// public int SupportedArticleId { get; set; }