- Domain: NotificationCategory enum, Notification entity, INotificationRepository - Infrastructure: NotificationConfiguration, NotificationRepository, AppDbContext/DI 등록 - Migration: AddNotificationTable 생성 및 적용 - Application: DTO 7개, INotificationService, NotificationService, DI 등록 - API: NotificationController (summary, list, read, read-all) Closes #247
31 lines
1.1 KiB
C#
31 lines
1.1 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
using SPMS.Domain.Entities;
|
|
|
|
namespace SPMS.Infrastructure.Persistence.Configurations;
|
|
|
|
public class NotificationConfiguration : IEntityTypeConfiguration<Notification>
|
|
{
|
|
public void Configure(EntityTypeBuilder<Notification> builder)
|
|
{
|
|
builder.ToTable("Notification");
|
|
|
|
builder.HasKey(e => e.Id);
|
|
builder.Property(e => e.Id).ValueGeneratedOnAdd();
|
|
|
|
builder.Property(e => e.Title).HasMaxLength(200).IsRequired();
|
|
builder.Property(e => e.Content).HasMaxLength(1000).IsRequired();
|
|
builder.Property(e => e.LinkUrl).HasMaxLength(500);
|
|
builder.Property(e => e.IsRead).IsRequired().HasDefaultValue(false);
|
|
builder.Property(e => e.CreatedAt).IsRequired();
|
|
|
|
builder.HasOne(e => e.TargetAdmin)
|
|
.WithMany()
|
|
.HasForeignKey(e => e.TargetAdminId)
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
builder.HasIndex(e => new { e.TargetAdminId, e.CreatedAt });
|
|
builder.HasIndex(e => new { e.TargetAdminId, e.IsRead });
|
|
}
|
|
}
|