添加项目文件。

This commit is contained in:
2026-05-09 17:06:30 +08:00
parent c60f5fe117
commit 720ef957d4
378 changed files with 14843 additions and 0 deletions
@@ -0,0 +1,35 @@
using ContactService.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace ContactService.Infrastructure.Configs
{
public class FriendConfig : IEntityTypeConfiguration<Friend>
{
public void Configure(EntityTypeBuilder<Friend> builder)
{
builder.ToTable("friends");
builder.HasKey(x => x.Id);
builder.OwnsOne(x => x.Owner, owner =>
{
owner.WithOwner(); // 🔥 关键:明确归属
owner.Property(p => p.Id).HasColumnName("OwnerId").IsRequired();
owner.Property(p => p.NickName).HasColumnName("OwnerNickName");
owner.Property(p => p.Avatar).HasColumnName("OwnerAvatarUrl");
});
builder.OwnsOne(x => x.Target, target =>
{
target.WithOwner(); // 🔥 关键
target.Property(p => p.Id).HasColumnName("TargetId").IsRequired();
target.Property(p => p.NickName).HasColumnName("TargetNickName");
target.Property(p => p.Avatar).HasColumnName("TargetAvatarUrl");
});
}
}
}
@@ -0,0 +1,20 @@
using ContactService.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace ContactService.Infrastructure.Configs
{
public class FriendRequestConfig : IEntityTypeConfiguration<FriendRequest>
{
public void Configure(EntityTypeBuilder<FriendRequest> builder)
{
builder.ToTable("friend_requests");
builder.HasKey(x => x.Id);
builder.HasIndex(x => new { x.OwnerId, x.TargetId });
}
}
}