feat(dal): добавлен Shortcode "%СВЯЗИ-ПН%", добавлен метод GetAvailableShortcodesAsync для отображения доступных изменямеых частей в API

This commit is contained in:
Mikhail Kuznetsov
2025-12-10 11:55:58 +10:00
parent 2f07ccd67c
commit 3a136f5bf4
12 changed files with 294 additions and 53 deletions

View File

@@ -0,0 +1,53 @@
using AutoMapper;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using PARR.API.Contracts.V1;
using PARR.API.Contracts.V1.Responses;
using PARR.API.Contracts.V1.Responses.Base;
using PARR.API.Controllers.V1.Base;
using PARR.Constants;
using PARR.DAL.DomainServices.Interfaces;
namespace PARR.API.Controllers.V1
{
/// <summary>
/// Переменные составляющие полей объектов платформы автоматизации регламентных работ
/// </summary>
[Authorize(Roles = ParrRoles.Administrator.Role)]
public class ShortcodeController : BaseApiController
{
private readonly ILogger<ShortcodeController> logger;
private readonly IShortcodesService shortcodesService;
private readonly IMapper mapper;
public ShortcodeController(
ILogger<ShortcodeController> logger,
IShortcodesService shortcodesService,
IMapper mapper
)
{
this.logger = logger;
this.shortcodesService = shortcodesService;
this.mapper = mapper;
}
/// <summary>
/// Получить список всех переменных составляющих
/// </summary>
/// <returns></returns>
[HttpGet(ApiRoutes.Shortcode.GetAll)]
public async Task<IActionResult> GetAll()
{
var shortcodes = await shortcodesService.GetAvailableShortcodesAsync();
if (!shortcodes.Any())
return NoContent();
var response = mapper.Map<List<ShortcodeResponse>>(shortcodes);
return Ok(new Response<List<ShortcodeResponse>>(response, true));
}
}
}