джоба есть
Tests / frontend-test (pull_request) Successful in 47s
Tests / backend-test (pull_request) Successful in 2m7s

This commit is contained in:
gorbenko.pavel
2026-08-17 14:14:45 +05:00
parent 48ede1420d
commit 2a7130c37f
25 changed files with 1533 additions and 5 deletions
@@ -0,0 +1,37 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Tnsu.ApprovalRoute.Api.Common;
using Tnsu.ApprovalRoute.Application.RequestTypeLists;
namespace Tnsu.ApprovalRoute.Api.Controllers;
/// <summary>
/// Нумерованная серия SharePoint-списков по типу заявок: куда писать сейчас и вся
/// серия для админки.
/// </summary>
[ApiController]
[Authorize]
[Route("api/request-types/{requestTypeId:int}/lists")]
[Produces("application/json")]
public sealed class RequestTypeListsController(RequestTypeListService service) : ControllerBase
{
/// <summary>Вся серия списков типа заявок (архив + текущий), от первого к последнему.</summary>
[HttpGet]
[ProducesResponseType(typeof(ApiResponse<IReadOnlyList<RequestTypeListDto>>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ApiError), StatusCodes.Status404NotFound)]
public async Task<IActionResult> List(int requestTypeId, CancellationToken ct) =>
(await service.ListAsync(requestTypeId, ct)).ToActionResult();
/// <summary>
/// Список, в который нужно писать новые заявки этого типа.
///
/// Не чистый GET: если список добрал порог элементов, запрос ставит в очередь
/// фоновую задачу создания следующего (см. RequestTypeListService.GetCurrentAsync).
/// </summary>
[HttpGet("current")]
[ProducesResponseType(typeof(ApiResponse<CurrentRequestTypeListDto>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ApiError), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ApiError), StatusCodes.Status404NotFound)]
public async Task<IActionResult> Current(int requestTypeId, CancellationToken ct) =>
(await service.GetCurrentAsync(requestTypeId, ct)).ToActionResult();
}
+17
View File
@@ -1,5 +1,7 @@
using System.Text.Json.Serialization;
using Extensions.Hosting.AsyncInitialization;
using Hangfire;
using Hangfire.PostgreSql;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.Extensions.DependencyInjection;
@@ -10,6 +12,7 @@ using Tnsu.ApprovalRoute.Api.Auth;
using Tnsu.ApprovalRoute.Api.Filters;
using Tnsu.ApprovalRoute.Application;
using Tnsu.ApprovalRoute.Application.Reminders;
using Tnsu.ApprovalRoute.Application.RequestTypeLists;
using Tnsu.ApprovalRoute.Application.Common.Interfaces;
using Tnsu.ApprovalRoute.Infrastructure;
@@ -37,6 +40,20 @@ builder.Services.AddCors(options =>
builder.Services.AddApprovalRouteInfrastructure(builder.Configuration);
builder.Services.AddApprovalRouteApplication();
builder.Services.Configure<RemindersOptions>(builder.Configuration.GetSection("Reminders"));
builder.Services.Configure<ListProvisioningOptions>(builder.Configuration.GetSection("ListProvisioning"));
// Hangfire на том же Postgres, что и остальные данные. Свои таблицы он создаёт сам
// (схема hangfire) при старте — отдельной EF-миграции для них не нужно.
builder.Services.AddHangfire(configuration => configuration
.SetDataCompatibilityLevel(CompatibilityLevel.Version_180)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UsePostgreSqlStorage(postgres =>
postgres.UseNpgsqlConnection(builder.Configuration.GetConnectionString("Postgres"))));
// Воркер живёт в процессе API: задач мало (создание списка — редкое событие), и
// отдельный хост под них был бы лишней инфраструктурой.
builder.Services.AddHangfireServer();
builder.Services.AddApprovalRouteAuth(builder.Configuration);
builder.Services.AddScoped<ICurrentUser, CurrentUserAccessor>();
builder.Services.AddOpenApi(options =>
@@ -5,6 +5,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Extensions.Hosting.AsyncInitialization" />
<PackageReference Include="Hangfire.AspNetCore" />
<PackageReference Include="Hangfire.PostgreSql" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
@@ -19,6 +19,11 @@
"https://localhost:4321"
]
},
"ListProvisioning": {
"ItemCountThreshold": 4500,
"StaleLockAfter": "00:30:00",
"CheckThresholdOnRead": true
},
"SharePoint": {
"TenantId": "b4c2af35-bfd6-4cff-9af9-556efb53e65a",
"ClientId": "9232d9e2-9807-4753-808f-07250e5474b0",