Сделал страничку для добавления принтера, так же добавил несколько доп классов, а так же марщрут для получения информации на указанный OID по SNMP

This commit is contained in:
Hukuta committed 2026-05-31 22:49:06 +09:00
1 parent a21834508d
commit 6e0d61aa6e
22 files changed
+348 -23

No files matched your search

@@ -1,8 +1,13 @@
namespace CartriX.Api.Controllers.Cartridge
using CartriX.Api.Entities;
namespace CartriX.Api.Controllers.Cartridge
{
public interface IPrinterService
{
public Task PrinterAddAsync(Shared.Models.Printer.PrinterAdd printer);
public Task<Entities.Printer?> GetPrinterAsync(int Id);
public Task<List<PrinterConnetctionType>> GetListConnectionTypeAsync();
public Task<List<PrinterPrintType>> GetListPrintTypeAsync();
}
}
@@ -5,13 +5,8 @@ namespace CartriX.Api.Controllers.Printer
{
[Route("api/[controller]")]
[ApiController]
public class PrinterController : ControllerBase
public class PrinterController(IPrinterService _printerService) : ControllerBase
{
private readonly IPrinterService _printerService;
public PrinterController(IPrinterService printerService)
{
_printerService = printerService;
}
/// <summary>
/// Добавить принтер
/// </summary>
@@ -41,6 +36,25 @@ namespace CartriX.Api.Controllers.Printer
var cartridge = await _printerService.GetPrinterAsync(Id);
return (cartridge is not null) ? StatusCode(200, cartridge.ToItem()) : StatusCode(404, $"Принтер с идентификатором \"{Id}\" не найден.");
}
/// <summary>
/// Получить список типов подключения принтеров
/// </summary>
[ProducesResponseType(typeof(List<Shared.Models.Printer.PrinterConnectionTypeItem>), StatusCodes.Status200OK)]
[HttpGet(nameof(ListConnectionType))]
public async Task<ActionResult> ListConnectionType()
{
var result = await _printerService.GetListConnectionTypeAsync();
return Ok(result.Select(t => t.ToItem()));
}
/// <summary>
/// Получить список типов печати принтеров
/// </summary>
[ProducesResponseType(typeof(List<Shared.Models.Printer.PrinterPrintTypeItem>), StatusCodes.Status200OK)]
[HttpGet(nameof(ListPrintType))]
public async Task<ActionResult> ListPrintType()
{
var result = await _printerService.GetListPrintTypeAsync();
return Ok(result.Select(t => t.ToItem()));
}
}
}
@@ -29,6 +29,16 @@ namespace CartriX.Api.Controllers.Cartridge
Model = printer.Model.ToItem(),
StatusId = printer.StatusId
};
public static Shared.Models.Printer.PrinterConnectionTypeItem ToItem(this Entities.PrinterConnetctionType type) => new()
{
Id = type.Id,
Name = type.Name
};
public static Shared.Models.Printer.PrinterPrintTypeItem ToItem(this Entities.PrinterPrintType type) => new()
{
Id = type.Id,
Name = type.Name
};
}
}
@@ -50,5 +50,15 @@ namespace CartriX.Api.Controllers.Cartridge
.Include(p => p.InstalledCartridge)
.Include(p => p.Location)
.FirstOrDefaultAsync(c => c.Id == Id);
/// <summary>
/// Получение списка типов подключения принтера
/// </summary>
/// <returns>Список объекта PrinterConnetctionType</returns>
public async Task<List<PrinterConnetctionType>> GetListConnectionTypeAsync() => await _context.PrinterConnetctionTypes.ToListAsync();
/// <summary>
/// Получение списка типов печати принтера
/// </summary>
/// <returns>Список объекта PrinterConnetctionType</returns>
public async Task<List<PrinterPrintType>> GetListPrintTypeAsync() => await _context.PrinterPrintTypes.ToListAsync();
}
}