From 5e3ef814f3eac6399065c3bf27fc543c4e7f66ad Mon Sep 17 00:00:00 2001 From: "gorbenko.pavel" Date: Fri, 24 Jul 2026 13:57:30 +0500 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D1=88=D0=BB=D0=B8=20?= =?UTF-8?q?=D0=BD=D0=B0=20int?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/RequestTypesController.cs | 12 ++++---- .../TemplateRouteStepsController.cs | 18 ++++++------ .../Controllers/TemplateRoutesController.cs | 14 ++++----- .../Common/Errors/ApiErrors.cs | 2 +- .../RequestTypes/RequestTypeDto.cs | 2 +- .../RequestTypes/RequestTypeService.cs | 6 ++-- .../TemplateRouteStepDto.cs | 4 +-- .../TemplateRouteStepService.cs | 10 +++---- .../TemplateRoutes/ResolveTemplateRouteDto.cs | 6 ++-- .../TemplateRoutes/TemplateRouteDto.cs | 6 ++-- .../TemplateRoutes/TemplateRouteService.cs | 12 ++++---- .../Entities/RequestType.cs | 5 +--- .../Entities/TemplateRoute.cs | 4 +-- .../Entities/TemplateRouteStep.cs | 4 +-- ... 20260724085143_InitialCreate.Designer.cs} | 29 +++++++++++-------- ...ate.cs => 20260724085143_InitialCreate.cs} | 17 ++++++----- .../ApprovalRouteDbContextModelSnapshot.cs | 27 ++++++++++------- .../RequestTypeServiceTests.cs | 4 +-- .../TemplateRouteServiceTests.cs | 6 ++-- .../TemplateRouteStepServiceTests.cs | 4 +-- 20 files changed, 101 insertions(+), 91 deletions(-) rename backend/src/Tnsu.ApprovalRoute.Infrastructure/Persistence/Migrations/{20260724071302_InitialCreate.Designer.cs => 20260724085143_InitialCreate.Designer.cs} (89%) rename backend/src/Tnsu.ApprovalRoute.Infrastructure/Persistence/Migrations/{20260724071302_InitialCreate.cs => 20260724085143_InitialCreate.cs} (82%) diff --git a/backend/src/Tnsu.ApprovalRoute.Api/Controllers/RequestTypesController.cs b/backend/src/Tnsu.ApprovalRoute.Api/Controllers/RequestTypesController.cs index da668c7..4cef00c 100644 --- a/backend/src/Tnsu.ApprovalRoute.Api/Controllers/RequestTypesController.cs +++ b/backend/src/Tnsu.ApprovalRoute.Api/Controllers/RequestTypesController.cs @@ -16,10 +16,10 @@ public sealed class RequestTypesController(RequestTypeService service) : Control public async Task List(CancellationToken ct) => (await service.ListAsync(ct)).ToActionResult(); - [HttpGet("{id:guid}")] + [HttpGet("{id:int}")] [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ApiError), StatusCodes.Status404NotFound)] - public async Task Get(Guid id, CancellationToken ct) => + public async Task Get(int id, CancellationToken ct) => (await service.GetAsync(id, ct)).ToActionResult(); [HttpPost] @@ -28,16 +28,16 @@ public sealed class RequestTypesController(RequestTypeService service) : Control public async Task Create(CreateRequestTypeRequest body, CancellationToken ct) => (await service.CreateAsync(body, ct)).ToActionResult(); - [HttpPut("{id:guid}")] + [HttpPut("{id:int}")] [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ApiError), StatusCodes.Status400BadRequest)] [ProducesResponseType(typeof(ApiError), StatusCodes.Status404NotFound)] - public async Task Update(Guid id, UpdateRequestTypeRequest body, CancellationToken ct) => + public async Task Update(int id, UpdateRequestTypeRequest body, CancellationToken ct) => (await service.UpdateAsync(id, body, ct)).ToActionResult(); - [HttpDelete("{id:guid}")] + [HttpDelete("{id:int}")] [ProducesResponseType(StatusCodes.Status204NoContent)] [ProducesResponseType(typeof(ApiError), StatusCodes.Status404NotFound)] - public async Task Delete(Guid id, CancellationToken ct) => + public async Task Delete(int id, CancellationToken ct) => (await service.DeleteAsync(id, ct)).ToActionResult(); } diff --git a/backend/src/Tnsu.ApprovalRoute.Api/Controllers/TemplateRouteStepsController.cs b/backend/src/Tnsu.ApprovalRoute.Api/Controllers/TemplateRouteStepsController.cs index 780f5a5..a7e6771 100644 --- a/backend/src/Tnsu.ApprovalRoute.Api/Controllers/TemplateRouteStepsController.cs +++ b/backend/src/Tnsu.ApprovalRoute.Api/Controllers/TemplateRouteStepsController.cs @@ -7,38 +7,38 @@ namespace Tnsu.ApprovalRoute.Api.Controllers; [ApiController] [Authorize] -[Route("api/template-routes/{routeId:guid}/steps")] +[Route("api/template-routes/{routeId:int}/steps")] [Produces("application/json")] public sealed class TemplateRouteStepsController(TemplateRouteStepService service) : ControllerBase { [HttpGet] [ProducesResponseType(typeof(ApiResponse>), StatusCodes.Status200OK)] - public async Task List(Guid routeId, CancellationToken ct) => + public async Task List(int routeId, CancellationToken ct) => (await service.ListAsync(routeId, ct)).ToActionResult(); - [HttpGet("{id:guid}")] + [HttpGet("{id:int}")] [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ApiError), StatusCodes.Status404NotFound)] - public async Task Get(Guid routeId, Guid id, CancellationToken ct) => + public async Task Get(int routeId, int id, CancellationToken ct) => (await service.GetAsync(routeId, id, ct)).ToActionResult(); [HttpPost] [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ApiError), StatusCodes.Status400BadRequest)] [ProducesResponseType(typeof(ApiError), StatusCodes.Status404NotFound)] - public async Task Create(Guid routeId, CreateTemplateRouteStepRequest body, CancellationToken ct) => + public async Task Create(int routeId, CreateTemplateRouteStepRequest body, CancellationToken ct) => (await service.CreateAsync(routeId, body, ct)).ToActionResult(); - [HttpPut("{id:guid}")] + [HttpPut("{id:int}")] [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ApiError), StatusCodes.Status400BadRequest)] [ProducesResponseType(typeof(ApiError), StatusCodes.Status404NotFound)] - public async Task Update(Guid routeId, Guid id, UpdateTemplateRouteStepRequest body, CancellationToken ct) => + public async Task Update(int routeId, int id, UpdateTemplateRouteStepRequest body, CancellationToken ct) => (await service.UpdateAsync(routeId, id, body, ct)).ToActionResult(); - [HttpDelete("{id:guid}")] + [HttpDelete("{id:int}")] [ProducesResponseType(StatusCodes.Status204NoContent)] [ProducesResponseType(typeof(ApiError), StatusCodes.Status404NotFound)] - public async Task Delete(Guid routeId, Guid id, CancellationToken ct) => + public async Task Delete(int routeId, int id, CancellationToken ct) => (await service.DeleteAsync(routeId, id, ct)).ToActionResult(); } diff --git a/backend/src/Tnsu.ApprovalRoute.Api/Controllers/TemplateRoutesController.cs b/backend/src/Tnsu.ApprovalRoute.Api/Controllers/TemplateRoutesController.cs index 0569bf7..4a62d74 100644 --- a/backend/src/Tnsu.ApprovalRoute.Api/Controllers/TemplateRoutesController.cs +++ b/backend/src/Tnsu.ApprovalRoute.Api/Controllers/TemplateRoutesController.cs @@ -20,13 +20,13 @@ public sealed class TemplateRoutesController(TemplateRouteService service) : Con [HttpGet] [ProducesResponseType(typeof(ApiResponse>), StatusCodes.Status200OK)] - public async Task List([FromQuery] Guid? requestTypeId, CancellationToken ct) => + public async Task List([FromQuery] int? requestTypeId, CancellationToken ct) => (await service.ListAsync(requestTypeId, ct)).ToActionResult(); - [HttpGet("{id:guid}")] + [HttpGet("{id:int}")] [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ApiError), StatusCodes.Status404NotFound)] - public async Task Get(Guid id, CancellationToken ct) => + public async Task Get(int id, CancellationToken ct) => (await service.GetAsync(id, ct)).ToActionResult(); [HttpPost] @@ -37,17 +37,17 @@ public sealed class TemplateRoutesController(TemplateRouteService service) : Con public async Task Create(CreateTemplateRouteRequest body, CancellationToken ct) => (await service.CreateAsync(body, ct)).ToActionResult(); - [HttpPut("{id:guid}")] + [HttpPut("{id:int}")] [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ApiError), StatusCodes.Status400BadRequest)] [ProducesResponseType(typeof(ApiError), StatusCodes.Status404NotFound)] [ProducesResponseType(typeof(ApiError), StatusCodes.Status409Conflict)] - public async Task Update(Guid id, UpdateTemplateRouteRequest body, CancellationToken ct) => + public async Task Update(int id, UpdateTemplateRouteRequest body, CancellationToken ct) => (await service.UpdateAsync(id, body, ct)).ToActionResult(); - [HttpDelete("{id:guid}")] + [HttpDelete("{id:int}")] [ProducesResponseType(StatusCodes.Status204NoContent)] [ProducesResponseType(typeof(ApiError), StatusCodes.Status404NotFound)] - public async Task Delete(Guid id, CancellationToken ct) => + public async Task Delete(int id, CancellationToken ct) => (await service.DeleteAsync(id, ct)).ToActionResult(); } diff --git a/backend/src/Tnsu.ApprovalRoute.Application/Common/Errors/ApiErrors.cs b/backend/src/Tnsu.ApprovalRoute.Application/Common/Errors/ApiErrors.cs index 424fdef..e9518c8 100644 --- a/backend/src/Tnsu.ApprovalRoute.Application/Common/Errors/ApiErrors.cs +++ b/backend/src/Tnsu.ApprovalRoute.Application/Common/Errors/ApiErrors.cs @@ -2,7 +2,7 @@ using FluentResults; namespace Tnsu.ApprovalRoute.Application.Common.Errors; -public sealed class NotFoundError(string entity, Guid id) +public sealed class NotFoundError(string entity, object id) : Error($"{entity} с id {id} не найден."); public sealed class ValidationError(string message) : Error(message); diff --git a/backend/src/Tnsu.ApprovalRoute.Application/RequestTypes/RequestTypeDto.cs b/backend/src/Tnsu.ApprovalRoute.Application/RequestTypes/RequestTypeDto.cs index fe74c5b..1a1b481 100644 --- a/backend/src/Tnsu.ApprovalRoute.Application/RequestTypes/RequestTypeDto.cs +++ b/backend/src/Tnsu.ApprovalRoute.Application/RequestTypes/RequestTypeDto.cs @@ -1,6 +1,6 @@ namespace Tnsu.ApprovalRoute.Application.RequestTypes; -public sealed record RequestTypeDto(Guid Id, string Name, string PageUrl); +public sealed record RequestTypeDto(int Id, string Name, string PageUrl); public sealed record CreateRequestTypeRequest(string Name, string PageUrl); diff --git a/backend/src/Tnsu.ApprovalRoute.Application/RequestTypes/RequestTypeService.cs b/backend/src/Tnsu.ApprovalRoute.Application/RequestTypes/RequestTypeService.cs index 014b3a8..df914ee 100644 --- a/backend/src/Tnsu.ApprovalRoute.Application/RequestTypes/RequestTypeService.cs +++ b/backend/src/Tnsu.ApprovalRoute.Application/RequestTypes/RequestTypeService.cs @@ -18,7 +18,7 @@ public sealed class RequestTypeService(ApprovalRouteDbContext db) return Result.Ok>(items); } - public async Task> GetAsync(Guid id, CancellationToken cancellationToken) + public async Task> GetAsync(int id, CancellationToken cancellationToken) { var entity = await db.RequestTypes.AsNoTracking().FirstOrDefaultAsync(x => x.Id == id, cancellationToken); @@ -36,7 +36,7 @@ public sealed class RequestTypeService(ApprovalRouteDbContext db) return Result.Ok(ToDto(entity)); } - public async Task> UpdateAsync(Guid id, UpdateRequestTypeRequest request, CancellationToken cancellationToken) + public async Task> UpdateAsync(int id, UpdateRequestTypeRequest request, CancellationToken cancellationToken) { var entity = await db.RequestTypes.FirstOrDefaultAsync(x => x.Id == id, cancellationToken); if (entity is null) @@ -49,7 +49,7 @@ public sealed class RequestTypeService(ApprovalRouteDbContext db) return Result.Ok(ToDto(entity)); } - public async Task DeleteAsync(Guid id, CancellationToken cancellationToken) + public async Task DeleteAsync(int id, CancellationToken cancellationToken) { var entity = await db.RequestTypes.FirstOrDefaultAsync(x => x.Id == id, cancellationToken); if (entity is null) diff --git a/backend/src/Tnsu.ApprovalRoute.Application/TemplateRouteSteps/TemplateRouteStepDto.cs b/backend/src/Tnsu.ApprovalRoute.Application/TemplateRouteSteps/TemplateRouteStepDto.cs index 0a5f852..6966de9 100644 --- a/backend/src/Tnsu.ApprovalRoute.Application/TemplateRouteSteps/TemplateRouteStepDto.cs +++ b/backend/src/Tnsu.ApprovalRoute.Application/TemplateRouteSteps/TemplateRouteStepDto.cs @@ -3,14 +3,14 @@ using Tnsu.ApprovalRoute.Domain.Enums; namespace Tnsu.ApprovalRoute.Application.TemplateRouteSteps; public sealed record TemplateRouteStepDto( - Guid Id, + int Id, int OrderNo, string ExecutorEmail, string Position, ProjectRole ProjectRole, HeadType HeadType, RouteStepStatus Status, - Guid RouteId, + int RouteId, bool AllowReassignToOtherApprovers); public sealed record CreateTemplateRouteStepRequest( diff --git a/backend/src/Tnsu.ApprovalRoute.Application/TemplateRouteSteps/TemplateRouteStepService.cs b/backend/src/Tnsu.ApprovalRoute.Application/TemplateRouteSteps/TemplateRouteStepService.cs index 0ba617a..244c35b 100644 --- a/backend/src/Tnsu.ApprovalRoute.Application/TemplateRouteSteps/TemplateRouteStepService.cs +++ b/backend/src/Tnsu.ApprovalRoute.Application/TemplateRouteSteps/TemplateRouteStepService.cs @@ -9,7 +9,7 @@ namespace Tnsu.ApprovalRoute.Application.TemplateRouteSteps; public sealed class TemplateRouteStepService(ApprovalRouteDbContext db) { - public async Task>> ListAsync(Guid routeId, CancellationToken cancellationToken) + public async Task>> ListAsync(int routeId, CancellationToken cancellationToken) { var items = await db.TemplateRouteSteps.AsNoTracking() .Where(x => x.RouteId == routeId) @@ -21,7 +21,7 @@ public sealed class TemplateRouteStepService(ApprovalRouteDbContext db) return Result.Ok>(items); } - public async Task> GetAsync(Guid routeId, Guid id, CancellationToken cancellationToken) + public async Task> GetAsync(int routeId, int id, CancellationToken cancellationToken) { var entity = await db.TemplateRouteSteps.AsNoTracking() .FirstOrDefaultAsync(x => x.Id == id && x.RouteId == routeId, cancellationToken); @@ -31,7 +31,7 @@ public sealed class TemplateRouteStepService(ApprovalRouteDbContext db) : Result.Ok(ToDto(entity)); } - public async Task> CreateAsync(Guid routeId, CreateTemplateRouteStepRequest r, CancellationToken cancellationToken) + public async Task> CreateAsync(int routeId, CreateTemplateRouteStepRequest r, CancellationToken cancellationToken) { var route = await db.TemplateRoutes.FirstOrDefaultAsync(x => x.Id == routeId, cancellationToken); if (route is null) @@ -60,7 +60,7 @@ public sealed class TemplateRouteStepService(ApprovalRouteDbContext db) } public async Task> UpdateAsync( - Guid routeId, Guid id, UpdateTemplateRouteStepRequest r, CancellationToken cancellationToken) + int routeId, int id, UpdateTemplateRouteStepRequest r, CancellationToken cancellationToken) { var route = await db.TemplateRoutes.FirstOrDefaultAsync(x => x.Id == routeId, cancellationToken); if (route is null) @@ -87,7 +87,7 @@ public sealed class TemplateRouteStepService(ApprovalRouteDbContext db) return await AppendMissingProjectRoleWarningAsync(route, result, cancellationToken); } - public async Task DeleteAsync(Guid routeId, Guid id, CancellationToken cancellationToken) + public async Task DeleteAsync(int routeId, int id, CancellationToken cancellationToken) { var entity = await db.TemplateRouteSteps.FirstOrDefaultAsync(x => x.Id == id && x.RouteId == routeId, cancellationToken); if (entity is null) diff --git a/backend/src/Tnsu.ApprovalRoute.Application/TemplateRoutes/ResolveTemplateRouteDto.cs b/backend/src/Tnsu.ApprovalRoute.Application/TemplateRoutes/ResolveTemplateRouteDto.cs index 4868411..62dba0f 100644 --- a/backend/src/Tnsu.ApprovalRoute.Application/TemplateRoutes/ResolveTemplateRouteDto.cs +++ b/backend/src/Tnsu.ApprovalRoute.Application/TemplateRoutes/ResolveTemplateRouteDto.cs @@ -3,7 +3,7 @@ using Tnsu.ApprovalRoute.Domain.Enums; namespace Tnsu.ApprovalRoute.Application.TemplateRoutes; public sealed record ResolvedRouteStepDto( - Guid Id, + int Id, int OrderNo, string ExecutorEmail, string Position, @@ -13,13 +13,13 @@ public sealed record ResolvedRouteStepDto( bool AllowReassignToOtherApprovers); public sealed record ResolveTemplateRouteResultDto( - Guid RouteId, + int RouteId, RouteType RouteType, bool RequiresControl, IReadOnlyList Steps); public sealed record ResolveTemplateRouteRequest( - Guid RequestTypeId, + int RequestTypeId, string? UserEmail, Guid? ProjectId, RouteStepStatus Status); diff --git a/backend/src/Tnsu.ApprovalRoute.Application/TemplateRoutes/TemplateRouteDto.cs b/backend/src/Tnsu.ApprovalRoute.Application/TemplateRoutes/TemplateRouteDto.cs index 34eef9d..ff964c4 100644 --- a/backend/src/Tnsu.ApprovalRoute.Application/TemplateRoutes/TemplateRouteDto.cs +++ b/backend/src/Tnsu.ApprovalRoute.Application/TemplateRoutes/TemplateRouteDto.cs @@ -3,9 +3,9 @@ using Tnsu.ApprovalRoute.Domain.Enums; namespace Tnsu.ApprovalRoute.Application.TemplateRoutes; public sealed record TemplateRouteDto( - Guid Id, + int Id, RouteType RouteType, - Guid RequestTypeId, + int RequestTypeId, string? Department, string Company, bool ByProject, @@ -13,7 +13,7 @@ public sealed record TemplateRouteDto( public sealed record CreateTemplateRouteRequest( RouteType RouteType, - Guid RequestTypeId, + int RequestTypeId, string? Department, string Company, bool ByProject, diff --git a/backend/src/Tnsu.ApprovalRoute.Application/TemplateRoutes/TemplateRouteService.cs b/backend/src/Tnsu.ApprovalRoute.Application/TemplateRoutes/TemplateRouteService.cs index 89df532..24272d7 100644 --- a/backend/src/Tnsu.ApprovalRoute.Application/TemplateRoutes/TemplateRouteService.cs +++ b/backend/src/Tnsu.ApprovalRoute.Application/TemplateRoutes/TemplateRouteService.cs @@ -14,7 +14,7 @@ public sealed class TemplateRouteService( ITnsuPortalClient portalClient, ICurrentUser currentUser) { - public async Task>> ListAsync(Guid? requestTypeId, CancellationToken cancellationToken) + public async Task>> ListAsync(int? requestTypeId, CancellationToken cancellationToken) { var query = db.TemplateRoutes.AsNoTracking().AsQueryable(); if (requestTypeId is { } id) @@ -28,7 +28,7 @@ public sealed class TemplateRouteService( return Result.Ok>(items); } - public async Task> GetAsync(Guid id, CancellationToken cancellationToken) + public async Task> GetAsync(int id, CancellationToken cancellationToken) { var entity = await db.TemplateRoutes.AsNoTracking().FirstOrDefaultAsync(x => x.Id == id, cancellationToken); @@ -64,7 +64,7 @@ public sealed class TemplateRouteService( return Result.Ok(ToDto(entity)); } - public async Task> UpdateAsync(Guid id, UpdateTemplateRouteRequest r, CancellationToken cancellationToken) + public async Task> UpdateAsync(int id, UpdateTemplateRouteRequest r, CancellationToken cancellationToken) { var entity = await db.TemplateRoutes.FirstOrDefaultAsync(x => x.Id == id, cancellationToken); if (entity is null) @@ -86,7 +86,7 @@ public sealed class TemplateRouteService( return Result.Ok(ToDto(entity)); } - public async Task DeleteAsync(Guid id, CancellationToken cancellationToken) + public async Task DeleteAsync(int id, CancellationToken cancellationToken) { var entity = await db.TemplateRoutes.FirstOrDefaultAsync(x => x.Id == id, cancellationToken); if (entity is null) @@ -113,7 +113,7 @@ public sealed class TemplateRouteService( var employee = await portalClient.GetEmployeeByEmailAsync(email, cancellationToken); if (employee is null) return Result.Fail( - new NotFoundError("Сотрудник по email в справочнике api.tnsu.kz не найден", Guid.Empty)); + new NotFoundError("Сотрудник в справочнике api.tnsu.kz по email", email)); var byProject = request.ProjectId is not null; var department = Normalize(employee.Department); @@ -154,7 +154,7 @@ public sealed class TemplateRouteService( } private Task HasDuplicateAsync( - Guid requestTypeId, string? department, string company, bool byProject, Guid? excludeId, CancellationToken cancellationToken) => + int requestTypeId, string? department, string company, bool byProject, int? excludeId, CancellationToken cancellationToken) => db.TemplateRoutes.AnyAsync(x => x.Id != excludeId && x.RequestTypeId == requestTypeId && diff --git a/backend/src/Tnsu.ApprovalRoute.Domain/Entities/RequestType.cs b/backend/src/Tnsu.ApprovalRoute.Domain/Entities/RequestType.cs index df43cbb..d86af83 100644 --- a/backend/src/Tnsu.ApprovalRoute.Domain/Entities/RequestType.cs +++ b/backend/src/Tnsu.ApprovalRoute.Domain/Entities/RequestType.cs @@ -1,11 +1,8 @@ -using System; -using System.Collections.Generic; - namespace Tnsu.ApprovalRoute.Domain.Entities; public class RequestType { - public Guid Id { get; set; } = Guid.NewGuid(); + public int Id { get; set; } public string Name { get; set; } = string.Empty; public string PageUrl { get; set; } = string.Empty; diff --git a/backend/src/Tnsu.ApprovalRoute.Domain/Entities/TemplateRoute.cs b/backend/src/Tnsu.ApprovalRoute.Domain/Entities/TemplateRoute.cs index 9c0a675..a691c75 100644 --- a/backend/src/Tnsu.ApprovalRoute.Domain/Entities/TemplateRoute.cs +++ b/backend/src/Tnsu.ApprovalRoute.Domain/Entities/TemplateRoute.cs @@ -4,9 +4,9 @@ namespace Tnsu.ApprovalRoute.Domain.Entities; public class TemplateRoute { - public Guid Id { get; set; } = Guid.NewGuid(); + public int Id { get; set; } public RouteType RouteType { get; set; } = RouteType.Sequential; - public Guid RequestTypeId { get; set; } + public int RequestTypeId { get; set; } // Компания и отдел инициатора — названия из справочника AD (api-tnsu-portal /Employee/ByEmail), // хранятся строками без FK в этой БД. Отдел опционален, компания обязательна. diff --git a/backend/src/Tnsu.ApprovalRoute.Domain/Entities/TemplateRouteStep.cs b/backend/src/Tnsu.ApprovalRoute.Domain/Entities/TemplateRouteStep.cs index b9590b4..9eff50c 100644 --- a/backend/src/Tnsu.ApprovalRoute.Domain/Entities/TemplateRouteStep.cs +++ b/backend/src/Tnsu.ApprovalRoute.Domain/Entities/TemplateRouteStep.cs @@ -4,7 +4,7 @@ namespace Tnsu.ApprovalRoute.Domain.Entities; public class TemplateRouteStep { - public Guid Id { get; set; } = Guid.NewGuid(); + public int Id { get; set; } public int OrderNo { get; set; } // Внешняя ссылка на пользователя (1С/ZUP) — без локальной таблицы Users. @@ -14,7 +14,7 @@ public class TemplateRouteStep public HeadType HeadType { get; set; } = HeadType.None; public RouteStepStatus Status { get; set; } = RouteStepStatus.Approval; - public Guid RouteId { get; set; } + public int RouteId { get; set; } public bool AllowReassignToOtherApprovers { get; set; } public TemplateRoute? Route { get; set; } diff --git a/backend/src/Tnsu.ApprovalRoute.Infrastructure/Persistence/Migrations/20260724071302_InitialCreate.Designer.cs b/backend/src/Tnsu.ApprovalRoute.Infrastructure/Persistence/Migrations/20260724085143_InitialCreate.Designer.cs similarity index 89% rename from backend/src/Tnsu.ApprovalRoute.Infrastructure/Persistence/Migrations/20260724071302_InitialCreate.Designer.cs rename to backend/src/Tnsu.ApprovalRoute.Infrastructure/Persistence/Migrations/20260724085143_InitialCreate.Designer.cs index a472fbc..ff4bd31 100644 --- a/backend/src/Tnsu.ApprovalRoute.Infrastructure/Persistence/Migrations/20260724071302_InitialCreate.Designer.cs +++ b/backend/src/Tnsu.ApprovalRoute.Infrastructure/Persistence/Migrations/20260724085143_InitialCreate.Designer.cs @@ -1,5 +1,4 @@ // -using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; @@ -12,7 +11,7 @@ using Tnsu.ApprovalRoute.Infrastructure.Persistence; namespace Tnsu.ApprovalRoute.Infrastructure.Persistence.Migrations { [DbContext(typeof(ApprovalRouteDbContext))] - [Migration("20260724071302_InitialCreate")] + [Migration("20260724085143_InitialCreate")] partial class InitialCreate { /// @@ -27,11 +26,13 @@ namespace Tnsu.ApprovalRoute.Infrastructure.Persistence.Migrations modelBuilder.Entity("Tnsu.ApprovalRoute.Domain.Entities.RequestType", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid") + .HasColumnType("integer") .HasColumnName("id"); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("Name") .IsRequired() .HasMaxLength(256) @@ -52,11 +53,13 @@ namespace Tnsu.ApprovalRoute.Infrastructure.Persistence.Migrations modelBuilder.Entity("Tnsu.ApprovalRoute.Domain.Entities.TemplateRoute", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid") + .HasColumnType("integer") .HasColumnName("id"); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("ByProject") .HasColumnType("boolean") .HasColumnName("by_project"); @@ -72,8 +75,8 @@ namespace Tnsu.ApprovalRoute.Infrastructure.Persistence.Migrations .HasColumnType("character varying(256)") .HasColumnName("department"); - b.Property("RequestTypeId") - .HasColumnType("uuid") + b.Property("RequestTypeId") + .HasColumnType("integer") .HasColumnName("request_type_id"); b.Property("RequiresControl") @@ -98,11 +101,13 @@ namespace Tnsu.ApprovalRoute.Infrastructure.Persistence.Migrations modelBuilder.Entity("Tnsu.ApprovalRoute.Domain.Entities.TemplateRouteStep", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid") + .HasColumnType("integer") .HasColumnName("id"); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("AllowReassignToOtherApprovers") .HasColumnType("boolean") .HasColumnName("allow_reassign_to_other_approvers"); @@ -135,8 +140,8 @@ namespace Tnsu.ApprovalRoute.Infrastructure.Persistence.Migrations .HasColumnType("character varying(32)") .HasColumnName("project_role"); - b.Property("RouteId") - .HasColumnType("uuid") + b.Property("RouteId") + .HasColumnType("integer") .HasColumnName("route_id"); b.Property("Status") diff --git a/backend/src/Tnsu.ApprovalRoute.Infrastructure/Persistence/Migrations/20260724071302_InitialCreate.cs b/backend/src/Tnsu.ApprovalRoute.Infrastructure/Persistence/Migrations/20260724085143_InitialCreate.cs similarity index 82% rename from backend/src/Tnsu.ApprovalRoute.Infrastructure/Persistence/Migrations/20260724071302_InitialCreate.cs rename to backend/src/Tnsu.ApprovalRoute.Infrastructure/Persistence/Migrations/20260724085143_InitialCreate.cs index 8645c1f..413382c 100644 --- a/backend/src/Tnsu.ApprovalRoute.Infrastructure/Persistence/Migrations/20260724071302_InitialCreate.cs +++ b/backend/src/Tnsu.ApprovalRoute.Infrastructure/Persistence/Migrations/20260724085143_InitialCreate.cs @@ -1,5 +1,5 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable @@ -15,7 +15,8 @@ namespace Tnsu.ApprovalRoute.Infrastructure.Persistence.Migrations name: "request_types", columns: table => new { - id = table.Column(type: "uuid", nullable: false), + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), name = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), page_url = table.Column(type: "character varying(512)", maxLength: 512, nullable: false) }, @@ -28,9 +29,10 @@ namespace Tnsu.ApprovalRoute.Infrastructure.Persistence.Migrations name: "template_routes", columns: table => new { - id = table.Column(type: "uuid", nullable: false), + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), route_type = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), - request_type_id = table.Column(type: "uuid", nullable: false), + request_type_id = table.Column(type: "integer", nullable: false), department = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), company = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), by_project = table.Column(type: "boolean", nullable: false), @@ -51,14 +53,15 @@ namespace Tnsu.ApprovalRoute.Infrastructure.Persistence.Migrations name: "template_route_steps", columns: table => new { - id = table.Column(type: "uuid", nullable: false), + id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), order_no = table.Column(type: "integer", nullable: false), executor_email = table.Column(type: "character varying(256)", maxLength: 256, nullable: false), position = table.Column(type: "character varying(128)", maxLength: 128, nullable: false), project_role = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), head_type = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), status = table.Column(type: "character varying(32)", maxLength: 32, nullable: false), - route_id = table.Column(type: "uuid", nullable: false), + route_id = table.Column(type: "integer", nullable: false), allow_reassign_to_other_approvers = table.Column(type: "boolean", nullable: false) }, constraints: table => diff --git a/backend/src/Tnsu.ApprovalRoute.Infrastructure/Persistence/Migrations/ApprovalRouteDbContextModelSnapshot.cs b/backend/src/Tnsu.ApprovalRoute.Infrastructure/Persistence/Migrations/ApprovalRouteDbContextModelSnapshot.cs index 73d526e..1043050 100644 --- a/backend/src/Tnsu.ApprovalRoute.Infrastructure/Persistence/Migrations/ApprovalRouteDbContextModelSnapshot.cs +++ b/backend/src/Tnsu.ApprovalRoute.Infrastructure/Persistence/Migrations/ApprovalRouteDbContextModelSnapshot.cs @@ -1,5 +1,4 @@ // -using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; @@ -24,11 +23,13 @@ namespace Tnsu.ApprovalRoute.Infrastructure.Persistence.Migrations modelBuilder.Entity("Tnsu.ApprovalRoute.Domain.Entities.RequestType", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid") + .HasColumnType("integer") .HasColumnName("id"); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("Name") .IsRequired() .HasMaxLength(256) @@ -49,11 +50,13 @@ namespace Tnsu.ApprovalRoute.Infrastructure.Persistence.Migrations modelBuilder.Entity("Tnsu.ApprovalRoute.Domain.Entities.TemplateRoute", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid") + .HasColumnType("integer") .HasColumnName("id"); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("ByProject") .HasColumnType("boolean") .HasColumnName("by_project"); @@ -69,8 +72,8 @@ namespace Tnsu.ApprovalRoute.Infrastructure.Persistence.Migrations .HasColumnType("character varying(256)") .HasColumnName("department"); - b.Property("RequestTypeId") - .HasColumnType("uuid") + b.Property("RequestTypeId") + .HasColumnType("integer") .HasColumnName("request_type_id"); b.Property("RequiresControl") @@ -95,11 +98,13 @@ namespace Tnsu.ApprovalRoute.Infrastructure.Persistence.Migrations modelBuilder.Entity("Tnsu.ApprovalRoute.Domain.Entities.TemplateRouteStep", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("uuid") + .HasColumnType("integer") .HasColumnName("id"); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("AllowReassignToOtherApprovers") .HasColumnType("boolean") .HasColumnName("allow_reassign_to_other_approvers"); @@ -132,8 +137,8 @@ namespace Tnsu.ApprovalRoute.Infrastructure.Persistence.Migrations .HasColumnType("character varying(32)") .HasColumnName("project_role"); - b.Property("RouteId") - .HasColumnType("uuid") + b.Property("RouteId") + .HasColumnType("integer") .HasColumnName("route_id"); b.Property("Status") diff --git a/backend/tests/Tnsu.ApprovalRoute.IntegrationTests/ApplicationServices/RequestTypeServiceTests.cs b/backend/tests/Tnsu.ApprovalRoute.IntegrationTests/ApplicationServices/RequestTypeServiceTests.cs index 83f8d38..a14b282 100644 --- a/backend/tests/Tnsu.ApprovalRoute.IntegrationTests/ApplicationServices/RequestTypeServiceTests.cs +++ b/backend/tests/Tnsu.ApprovalRoute.IntegrationTests/ApplicationServices/RequestTypeServiceTests.cs @@ -33,7 +33,7 @@ public sealed class RequestTypeServiceTests(PostgresDatabaseFixture fixture) : I public async Task GetAsync_UnknownId_ReturnsFailedResult() { // Action - var result = await _service.GetAsync(Guid.NewGuid(), CancellationToken.None); + var result = await _service.GetAsync(999999, CancellationToken.None); // Assert result.IsFailed.ShouldBeTrue(); @@ -60,7 +60,7 @@ public sealed class RequestTypeServiceTests(PostgresDatabaseFixture fixture) : I { // Action var result = await _service.UpdateAsync( - Guid.NewGuid(), new UpdateRequestTypeRequest("X", "/x"), CancellationToken.None); + 999999, new UpdateRequestTypeRequest("X", "/x"), CancellationToken.None); // Assert result.IsFailed.ShouldBeTrue(); diff --git a/backend/tests/Tnsu.ApprovalRoute.IntegrationTests/ApplicationServices/TemplateRouteServiceTests.cs b/backend/tests/Tnsu.ApprovalRoute.IntegrationTests/ApplicationServices/TemplateRouteServiceTests.cs index 59879e5..ce63527 100644 --- a/backend/tests/Tnsu.ApprovalRoute.IntegrationTests/ApplicationServices/TemplateRouteServiceTests.cs +++ b/backend/tests/Tnsu.ApprovalRoute.IntegrationTests/ApplicationServices/TemplateRouteServiceTests.cs @@ -34,7 +34,7 @@ public sealed class TemplateRouteServiceTests : IClassFixture(); } - private async Task CreateRequestTypeAsync(string name) => + private async Task CreateRequestTypeAsync(string name) => (await _requestTypeService.CreateAsync(new CreateRequestTypeRequest(name, $"/{name}"), CancellationToken.None)).Value.Id; [Fact(DisplayName = "Создание маршрута и получение его по Id возвращает сохранённые данные")] @@ -62,7 +62,7 @@ public sealed class TemplateRouteServiceTests : IClassFixture(); } - private async Task CreateRouteAsync(string requestTypeName, bool byProject) + private async Task CreateRouteAsync(string requestTypeName, bool byProject) { var requestTypeId = (await _requestTypeService.CreateAsync( new CreateRequestTypeRequest(requestTypeName, $"/{requestTypeName}"), CancellationToken.None)).Value.Id; @@ -41,7 +41,7 @@ public sealed class TemplateRouteStepServiceTests : IClassFixture