2026-11-18 18:32:59 +01:00
|
|
|
using Helpdesk.Domain.Catalogs;
|
|
|
|
|
using Helpdesk.Domain.Issues;
|
2026-11-18 21:58:33 +01:00
|
|
|
using Helpdesk.Domain.Notifications;
|
|
|
|
|
using Helpdesk.Domain.Proposals;
|
2026-11-18 18:32:59 +01:00
|
|
|
using Helpdesk.Domain.Users;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
|
|
|
|
|
|
namespace Helpdesk.Infrastructure.Persistence;
|
|
|
|
|
|
|
|
|
|
internal sealed class IssueConfiguration : IEntityTypeConfiguration<Issue>
|
|
|
|
|
{
|
|
|
|
|
public void Configure(EntityTypeBuilder<Issue> b)
|
|
|
|
|
{
|
|
|
|
|
b.ToTable("issue");
|
|
|
|
|
b.Property(x => x.Title).HasMaxLength(200);
|
|
|
|
|
b.Property(x => x.Description).HasColumnType("text");
|
|
|
|
|
b.Property(x => x.LocationDetail).HasMaxLength(255);
|
|
|
|
|
b.Property(x => x.Status).HasConversion<EnumCodeConverter<IssueStatus>>().HasMaxLength(30);
|
|
|
|
|
b.Property(x => x.Priority).HasConversion<EnumCodeConverter<IssuePriority>>().HasMaxLength(10);
|
|
|
|
|
b.Property(x => x.RowVersion).IsConcurrencyToken();
|
|
|
|
|
b.HasOne<IssueCategory>().WithMany().HasForeignKey(x => x.CategoryId);
|
|
|
|
|
b.HasOne<Building>().WithMany().HasForeignKey(x => x.BuildingId);
|
|
|
|
|
b.HasOne<User>().WithMany().HasForeignKey(x => x.ReporterId);
|
|
|
|
|
b.HasOne<User>().WithMany().HasForeignKey(x => x.AssigneeId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal sealed class IssueEventConfiguration : IEntityTypeConfiguration<IssueEvent>
|
|
|
|
|
{
|
|
|
|
|
public void Configure(EntityTypeBuilder<IssueEvent> b)
|
|
|
|
|
{
|
|
|
|
|
b.ToTable("issue_event");
|
|
|
|
|
b.Property(x => x.EventType).HasConversion<EnumCodeConverter<IssueEventType>>().HasMaxLength(20);
|
|
|
|
|
b.Property(x => x.FromStatus).HasConversion<EnumCodeConverter<IssueStatus>>().HasMaxLength(30);
|
|
|
|
|
b.Property(x => x.ToStatus).HasConversion<EnumCodeConverter<IssueStatus>>().HasMaxLength(30);
|
|
|
|
|
b.Property(x => x.Note).HasColumnType("text");
|
|
|
|
|
b.HasOne(x => x.Issue).WithMany().HasForeignKey(x => x.IssueId);
|
|
|
|
|
b.HasOne<User>().WithMany().HasForeignKey(x => x.ActorId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal sealed class AttachmentConfiguration : IEntityTypeConfiguration<Attachment>
|
|
|
|
|
{
|
|
|
|
|
public void Configure(EntityTypeBuilder<Attachment> b)
|
|
|
|
|
{
|
|
|
|
|
b.ToTable("attachment");
|
|
|
|
|
b.Property(x => x.OriginalFileName).HasMaxLength(255);
|
|
|
|
|
b.Property(x => x.StoredFileName).HasMaxLength(36);
|
|
|
|
|
b.Property(x => x.ContentType).HasMaxLength(100);
|
|
|
|
|
b.HasOne(x => x.Issue).WithMany().HasForeignKey(x => x.IssueId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-18 21:58:33 +01:00
|
|
|
internal sealed class NotificationConfiguration : IEntityTypeConfiguration<Notification>
|
2026-11-18 18:32:59 +01:00
|
|
|
{
|
2026-11-18 21:58:33 +01:00
|
|
|
public void Configure(EntityTypeBuilder<Notification> b)
|
2026-11-18 18:32:59 +01:00
|
|
|
{
|
|
|
|
|
b.ToTable("notification");
|
|
|
|
|
b.Property(x => x.Type).HasConversion<EnumCodeConverter<NotificationType>>().HasMaxLength(40);
|
|
|
|
|
b.Property(x => x.Title).HasMaxLength(200);
|
|
|
|
|
b.Property(x => x.Message).HasMaxLength(1000);
|
|
|
|
|
b.HasOne(x => x.Issue).WithMany().HasForeignKey(x => x.IssueId).IsRequired(false);
|
2026-11-18 21:58:33 +01:00
|
|
|
b.HasOne<Proposal>().WithMany().HasForeignKey(x => x.ProposalId);
|
2026-11-18 18:32:59 +01:00
|
|
|
b.HasOne<User>().WithMany().HasForeignKey(x => x.UserId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal sealed class NotificationDeliveryConfiguration : IEntityTypeConfiguration<NotificationDelivery>
|
|
|
|
|
{
|
|
|
|
|
public void Configure(EntityTypeBuilder<NotificationDelivery> b)
|
|
|
|
|
{
|
|
|
|
|
b.ToTable("notification_delivery");
|
|
|
|
|
b.Property(x => x.Channel).HasConversion<EnumCodeConverter<DeliveryChannel>>().HasMaxLength(10);
|
|
|
|
|
b.Property(x => x.Status).HasConversion<EnumCodeConverter<DeliveryStatus>>().HasMaxLength(10);
|
|
|
|
|
b.HasOne(x => x.Notification).WithMany().HasForeignKey(x => x.NotificationId);
|
|
|
|
|
}
|
|
|
|
|
}
|