using GroupService.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace GroupService.Infrastructure.Configs { public class GroupJoinRequestConfig : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("group_join_requests"); builder.HasKey(x => x.Id); builder.HasKey(x => new { x.GroupId, x.UserId }); builder.HasIndex(x => x.Id).IsUnique(); builder.HasIndex(x => new { x.GroupId, x.State, x.CreationTime }); builder.HasIndex(x => new { x.UserId, x.CreationTime }); builder.ComplexProperty(x => x.UserProfile, u => { u.Property(p => p.Avatar) .HasMaxLength(100); u.Property(p => p.NickName) .IsRequired() .HasMaxLength(20); }); builder.ComplexProperty(x => x.GroupProfile, u => { u.Property(p => p.Avatar) .IsRequired() .HasMaxLength(100); u.Property(p => p.GroupName) .IsRequired() .HasMaxLength(20); }); } } }