refactor: change PointsAccountId to Guid-based strongly typed ID

This commit is contained in:
movingsam 2026-02-17 15:30:10 +08:00
parent f3a0601257
commit ab3d755f63
3 changed files with 8 additions and 8 deletions

View File

@ -4,12 +4,12 @@ using NetCorePal.Extensions.Primitives;
namespace Fengling.Member.Domain.Aggregates.PointsModel;
public partial record PointsAccountId : IInt64StronglyTypedId
public partial record PointsAccountId : IGuidStronglyTypedId
{
public static PointsAccountId New() => new PointsAccountId(0);
public long Value => this;
public static implicit operator long(PointsAccountId id) => id.Value;
public static implicit operator PointsAccountId(long value) => new PointsAccountId(value);
public static PointsAccountId New() => new PointsAccountId(Guid.NewGuid());
public Guid Value => this;
public static implicit operator Guid(PointsAccountId id) => id.Value;
public static implicit operator PointsAccountId(Guid value) => new PointsAccountId(value);
}
public class PointsAccount : Entity<PointsAccountId>, IAggregateRoot

View File

@ -14,7 +14,7 @@ public class PointsAccountEntityTypeConfiguration : IEntityTypeConfiguration<Poi
builder.Property(p => p.Id)
.HasColumnName("id")
.UseSnowFlakeValueGenerator()
.UseGuidVersion7ValueGenerator()
.HasComment("积分账户标识");
builder.Property(p => p.MemberId)

View File

@ -2,7 +2,7 @@ using Fengling.Member.Domain.Aggregates.PointsModel;
namespace Fengling.Member.Infrastructure.Repositories;
public interface IPointsAccountRepository : IRepository<PointsAccount, long>
public interface IPointsAccountRepository : IRepository<PointsAccount, PointsAccountId>
{
Task<PointsAccount?> GetByMemberIdAsync(long memberId, CancellationToken cancellationToken = default);
Task<PointsAccount?> GetByMemberIdAndTenantIdAsync(long memberId, long tenantId, CancellationToken cancellationToken = default);
@ -12,7 +12,7 @@ public interface IPointsAccountRepository : IRepository<PointsAccount, long>
}
public class PointsAccountRepository(ApplicationDbContext context) :
RepositoryBase<PointsAccount, long, ApplicationDbContext>(context), IPointsAccountRepository
RepositoryBase<PointsAccount, PointsAccountId, ApplicationDbContext>(context), IPointsAccountRepository
{
public async Task<PointsAccount?> GetByMemberIdAsync(long memberId, CancellationToken cancellationToken = default)
{