RssNewsArticleConfiguration.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233
  1. using Domain.Entities.News;
  2. using Microsoft.EntityFrameworkCore;
  3. using Microsoft.EntityFrameworkCore.Metadata.Builders;
  4. namespace Infrastructure.Persistence.Configurations.News;
  5. public sealed class RssNewsArticleConfiguration : IEntityTypeConfiguration<RssNewsArticle>
  6. {
  7. public void Configure(EntityTypeBuilder<RssNewsArticle> builder)
  8. {
  9. builder.HasIndex(x => new { x.Guid, x.RssFeedSourceID }).IsUnique().HasFilter("[Guid] IS NOT NULL");
  10. builder.HasIndex(x => x.PublishedAt);
  11. builder.HasIndex(x => x.RssFeedSourceID);
  12. builder.HasIndex(x => x.CreatedAt);
  13. builder.ToTable(nameof(RssNewsArticle), t => t.HasComment("RSS 뉴스 기사"));
  14. builder.HasKey(x => x.ID);
  15. builder.Property(x => x.ID).ValueGeneratedOnAdd().HasComment("PK");
  16. builder.Property(x => x.RssFeedSourceID).IsRequired().HasComment("RSS 피드 소스 FK");
  17. builder.Property(x => x.Title).HasMaxLength(500).IsRequired().HasComment("기사 제목");
  18. builder.Property(x => x.Link).HasMaxLength(2000).HasComment("원본 링크");
  19. builder.Property(x => x.Guid).HasMaxLength(1000).HasComment("RSS GUID (중복 방지)");
  20. builder.Property(x => x.Author).HasMaxLength(200).HasComment("작성자");
  21. builder.Property(x => x.Description).HasColumnType("nvarchar(max)").HasComment("요약");
  22. builder.Property(x => x.Content).HasColumnType("nvarchar(max)").HasComment("본문 (content:encoded)");
  23. builder.Property(x => x.ImageUrl).HasMaxLength(2000).HasComment("썸네일 이미지 URL");
  24. builder.Property(x => x.SourceName).HasMaxLength(200).HasComment("출처명");
  25. builder.Property(x => x.Categories).HasColumnType("nvarchar(max)").HasComment("카테고리 (JSON 배열)");
  26. builder.Property(x => x.CommentCount).IsRequired().HasComment("댓글 수");
  27. builder.Property(x => x.PublishedAt).HasComment("발행 일시");
  28. builder.Property(x => x.CreatedAt).IsRequired().HasComment("수집 일시");
  29. }
  30. }