Создание таблиц для цепочек подтверждения #1

Merged
gorbenko.pavel merged 9 commits from db-structure into main 2026-07-23 04:55:25 +00:00
12 changed files with 141 additions and 0 deletions
Showing only changes of commit 7aae87d012 - Show all commits
+15
View File
@@ -0,0 +1,15 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/.idea.Tnsu.ApprovalRoute.iml
/modules.xml
/projectSettingsUpdater.xml
/contentModel.xml
# Editor-based HTTP Client requests
/httpRequests/
# Ignored default folder with query files
/queries/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
+1
View File
@@ -0,0 +1 @@
Tnsu.ApprovalRoute
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
@@ -1,3 +1,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Tnsu.ApprovalRoute.Application; using Tnsu.ApprovalRoute.Application;
using Tnsu.ApprovalRoute.Infrastructure; using Tnsu.ApprovalRoute.Infrastructure;
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
namespace Tnsu.ApprovalRoute.Domain.Entities;
public class RequestType
{
public Guid Id { get; set; } = Guid.NewGuid();
public string Name { get; set; } = string.Empty;
public string PageUrl { get; set; } = string.Empty;
public ICollection<Route> Routes { get; set; } = new List<Route>();
}
@@ -0,0 +1,20 @@
using Tnsu.ApprovalRoute.Domain.Enums;
namespace Tnsu.ApprovalRoute.Domain.Entities;
public class Route
{
public Guid Id { get; set; } = Guid.NewGuid();
public RouteType RouteType { get; set; } = RouteType.Sequential;
public Guid RequestTypeId { get; set; }
// Внешние справочники (1С/ZUP) — хранятся как ссылки без FK в этой БД.
public Guid DepartmentId { get; set; }
public Guid CompanyId { get; set; }
public Guid ProjectId { get; set; }
public bool RequiresControl { get; set; }
public RequestType? RequestType { get; set; }
public ICollection<RouteStep> Steps { get; set; } = new List<RouteStep>();
}
@@ -0,0 +1,19 @@
using Tnsu.ApprovalRoute.Domain.Enums;
namespace Tnsu.ApprovalRoute.Domain.Entities;
public class RouteStep
{
Review

Надо добавить поле Роль на проекте (enum)

Надо добавить поле Роль на проекте (enum)
Review

поправил

поправил
public Guid Id { get; set; } = Guid.NewGuid();
public int OrderNo { get; set; }
// Внешняя ссылка на пользователя (1С/ZUP) — без локальной таблицы Users.
public Guid ExecutorUserId { get; set; }
public string Position { get; set; } = string.Empty;
public RouteStepStatus Status { get; set; } = RouteStepStatus.Draft;
public Guid RouteId { get; set; }
public bool AllowReassignToOtherApprovers { get; set; }
public Route? Route { get; set; }
}
@@ -0,0 +1,12 @@
namespace Tnsu.ApprovalRoute.Domain.Enums;
public enum RouteStepStatus
{
Draft,
OnApproval,
Approved,
InExecution,
Completed,
Returned,
Closed
}
@@ -0,0 +1,7 @@
namespace Tnsu.ApprovalRoute.Domain.Enums;
public enum RouteType
{
Parallel,
Sequential
}
@@ -1,7 +1,40 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Tnsu.ApprovalRoute.Domain.Entities;
namespace Tnsu.ApprovalRoute.Infrastructure.Persistence; namespace Tnsu.ApprovalRoute.Infrastructure.Persistence;
public class ApprovalRouteDbContext(DbContextOptions<ApprovalRouteDbContext> options) : DbContext(options) public class ApprovalRouteDbContext(DbContextOptions<ApprovalRouteDbContext> options) : DbContext(options)
{ {
public DbSet<RequestType> RequestTypes => Set<RequestType>();
public DbSet<Route> Routes => Set<Route>();
public DbSet<RouteStep> RouteSteps => Set<RouteStep>();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<RequestType>(e =>
{
e.ToTable("request_types");
e.HasKey(x => x.Id);
e.Property(x => x.Name).HasMaxLength(256).IsRequired();
e.Property(x => x.PageUrl).HasMaxLength(512).IsRequired();
});
modelBuilder.Entity<Route>(e =>
{
e.ToTable("routes");
e.HasKey(x => x.Id);
e.Property(x => x.RouteType).HasConversion<string>().HasMaxLength(32).IsRequired();
e.HasOne(x => x.RequestType).WithMany(x => x.Routes).HasForeignKey(x => x.RequestTypeId);
});
modelBuilder.Entity<RouteStep>(e =>
{
e.ToTable("route_steps");
e.HasKey(x => x.Id);
e.Property(x => x.Position).HasMaxLength(128).IsRequired();
e.Property(x => x.Status).HasConversion<string>().HasMaxLength(32).IsRequired();
e.HasOne(x => x.Route).WithMany(x => x.Steps).HasForeignKey(x => x.RouteId);
e.HasIndex(x => new { x.RouteId, x.OrderNo });
});
}
} }