ref: project structure

This commit is contained in:
2026-08-19 23:25:08 +07:00
parent 05a93cfc09
commit a1fe31cf70
155 changed files with 3339 additions and 1007 deletions
@@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using mws.backend.dotnet.domain.Documents;
namespace mws.backend.dotnet.infrastructure.Persistence.Configuration;
public class DocumentConfiguration : IEntityTypeConfiguration<Document>
{
public void Configure(EntityTypeBuilder<Document> e)
{
e.ToTable("documents");
e.HasKey(d => d.Id);
e.Property(d => d.Title).HasMaxLength(300).IsRequired();
e.Property(d => d.Type).HasConversion<string>().HasMaxLength(20);
e.Property(d => d.Content).HasColumnType("text");
e.HasIndex(d => new { d.ProjectId, d.ParentId });
e.HasIndex(d => d.ParentId);
e.HasOne(d => d.Parent)
.WithMany(d => d.Children)
.HasForeignKey(d => d.ParentId)
.OnDelete(DeleteBehavior.Restrict);
}
}
@@ -0,0 +1,18 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using mws.backend.dotnet.domain.MasterData;
namespace mws.backend.dotnet.infrastructure.Persistence.Configuration;
public class MasterDataEntryConfiguration : IEntityTypeConfiguration<MasterDataEntry>
{
public void Configure(EntityTypeBuilder<MasterDataEntry> e)
{
e.ToTable("master_data");
e.HasKey(m => m.Id);
e.Property(m => m.Group).HasMaxLength(100).IsRequired();
e.Property(m => m.Label).HasMaxLength(200).IsRequired();
e.Property(m => m.Value).HasMaxLength(100).IsRequired();
e.HasIndex(m => new { m.Group, m.Value }).IsUnique();
}
}
@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using mws.backend.dotnet.domain.Projects;
namespace mws.backend.dotnet.infrastructure.Persistence.Configuration;
public class ProjectConfiguration : IEntityTypeConfiguration<Project>
{
public void Configure(EntityTypeBuilder<Project> e)
{
e.ToTable("projects");
e.HasKey(p => p.Id);
e.Property(p => p.Name).HasMaxLength(200).IsRequired();
e.Property(p => p.Description).HasMaxLength(2000);
e.Property(p => p.Status).HasConversion<string>().HasMaxLength(20);
e.HasIndex(p => p.CreatedBy);
e.HasIndex(p => p.UpdatedBy);
e.HasOne(p => p.CreatedByUser)
.WithMany()
.HasForeignKey(p => p.CreatedBy)
.OnDelete(DeleteBehavior.Restrict);
e.HasOne(p => p.UpdatedByUser)
.WithMany()
.HasForeignKey(p => p.UpdatedBy)
.OnDelete(DeleteBehavior.Restrict);
}
}
@@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using mws.backend.dotnet.domain.Projects;
namespace mws.backend.dotnet.infrastructure.Persistence.Configuration;
public class ProjectMemberConfiguration : IEntityTypeConfiguration<ProjectMember>
{
public void Configure(EntityTypeBuilder<ProjectMember> e)
{
e.ToTable("project_members");
e.HasKey(m => new { m.ProjectId, m.UserId });
e.Property(m => m.Role).HasConversion<string>().HasMaxLength(20);
e.HasOne(m => m.Project)
.WithMany(p => p.Members)
.HasForeignKey(m => m.ProjectId)
.OnDelete(DeleteBehavior.Cascade);
e.HasOne(m => m.User)
.WithMany()
.HasForeignKey(m => m.UserId)
.OnDelete(DeleteBehavior.Cascade);
}
}
@@ -0,0 +1,20 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using mws.backend.dotnet.domain.Projects;
namespace mws.backend.dotnet.infrastructure.Persistence.Configuration;
public class ProjectMemberPermissionConfiguration : IEntityTypeConfiguration<ProjectMemberPermission>
{
public void Configure(EntityTypeBuilder<ProjectMemberPermission> e)
{
e.ToTable("project_member_permissions");
e.HasKey(p => new { p.ProjectId, p.UserId, p.Screen });
e.Property(p => p.Screen).HasMaxLength(50).IsRequired();
e.HasOne<ProjectMember>()
.WithMany()
.HasForeignKey(p => new { p.ProjectId, p.UserId })
.OnDelete(DeleteBehavior.Cascade);
}
}
@@ -0,0 +1,16 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using mws.backend.dotnet.domain.Roles;
namespace mws.backend.dotnet.infrastructure.Persistence.Configuration;
public class RoleConfiguration : IEntityTypeConfiguration<Role>
{
public void Configure(EntityTypeBuilder<Role> e)
{
e.ToTable("roles");
e.HasKey(r => r.Id);
e.Property(r => r.Name).HasMaxLength(100).IsRequired();
e.HasIndex(r => r.Name).IsUnique();
}
}
@@ -0,0 +1,20 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using mws.backend.dotnet.domain.Roles;
namespace mws.backend.dotnet.infrastructure.Persistence.Configuration;
public class RolePermissionConfiguration : IEntityTypeConfiguration<RolePermission>
{
public void Configure(EntityTypeBuilder<RolePermission> e)
{
e.ToTable("role_permissions");
e.HasKey(p => new { p.RoleId, p.Screen });
e.Property(p => p.Screen).HasMaxLength(50).IsRequired();
e.HasOne(p => p.Role)
.WithMany(r => r.Permissions)
.HasForeignKey(p => p.RoleId)
.OnDelete(DeleteBehavior.Cascade);
}
}
@@ -0,0 +1,27 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using mws.backend.dotnet.domain.Tasks;
namespace mws.backend.dotnet.infrastructure.Persistence.Configuration;
public class TaskConfiguration : IEntityTypeConfiguration<TaskItem>
{
public void Configure(EntityTypeBuilder<TaskItem> e)
{
e.ToTable("tasks");
e.HasKey(t => t.Id);
e.Property(t => t.Title).HasMaxLength(300).IsRequired();
e.Property(t => t.Description).HasColumnType("text");
e.Property(t => t.Status).HasConversion<string>().HasMaxLength(20);
e.Property(t => t.Priority).HasConversion<string>().HasMaxLength(20);
e.HasIndex(t => t.ProjectId);
e.HasIndex(t => t.AssigneeId);
e.HasIndex(t => t.Status);
e.HasOne(t => t.Assignee)
.WithMany()
.HasForeignKey(t => t.AssigneeId)
.OnDelete(DeleteBehavior.SetNull);
}
}
@@ -0,0 +1,18 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using mws.backend.dotnet.domain.Users;
namespace mws.backend.dotnet.infrastructure.Persistence.Configuration;
public class UserConfiguration : IEntityTypeConfiguration<User>
{
public void Configure(EntityTypeBuilder<User> e)
{
e.ToTable("users");
e.HasKey(u => u.Id);
e.Property(u => u.Username).HasMaxLength(100).IsRequired();
e.HasIndex(u => u.Username).IsUnique();
e.Property(u => u.PasswordHash).HasMaxLength(200).IsRequired();
e.Property(u => u.DisplayName).HasMaxLength(150).IsRequired();
}
}
@@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using mws.backend.dotnet.domain.Users;
namespace mws.backend.dotnet.infrastructure.Persistence.Configuration;
public class UserRoleConfiguration : IEntityTypeConfiguration<UserRole>
{
public void Configure(EntityTypeBuilder<UserRole> e)
{
e.ToTable("user_roles");
e.HasKey(ur => new { ur.UserId, ur.RoleId });
e.HasOne(ur => ur.User)
.WithMany(u => u.UserRoles)
.HasForeignKey(ur => ur.UserId)
.OnDelete(DeleteBehavior.Cascade);
e.HasOne(ur => ur.Role)
.WithMany(r => r.UserRoles)
.HasForeignKey(ur => ur.RoleId)
.OnDelete(DeleteBehavior.Cascade);
}
}