refactor: apply CleanDDD strongly typed ID and add Deleted/RowVersion
- Convert CampaignId to partial record implementing IGuidStronglyTypedId - Add PointsAccountId as IInt64StronglyTypedId with Snowflake ID generation - Add Deleted and RowVersion to MemberEntity and PointsAccount - Update PointsAccountEntityTypeConfiguration to use SnowFlakeValueGenerator BREAKING CHANGE: PointsAccount now uses PointsAccountId (long) instead of plain long
This commit is contained in:
parent
92247346dd
commit
eb1d4ac4f7
@ -1,8 +1,18 @@
|
||||
using Fengling.Member.Domain.Events.Points;
|
||||
using NetCorePal.Extensions.Domain;
|
||||
using NetCorePal.Extensions.Primitives;
|
||||
|
||||
namespace Fengling.Member.Domain.Aggregates.PointsModel;
|
||||
|
||||
public class PointsAccount : Entity<long>, IAggregateRoot
|
||||
public partial record PointsAccountId : IInt64StronglyTypedId
|
||||
{
|
||||
public static PointsAccountId New() => new PointsAccountId(IdGenerator.Instance.GetLong());
|
||||
public long Value => this;
|
||||
public static implicit operator long(PointsAccountId id) => id.Value;
|
||||
public static implicit operator PointsAccountId(long value) => new PointsAccountId(value);
|
||||
}
|
||||
|
||||
public class PointsAccount : Entity<PointsAccountId>, IAggregateRoot
|
||||
{
|
||||
public long MemberId { get; private set; }
|
||||
public long TenantId { get; private set; }
|
||||
@ -12,6 +22,8 @@ public class PointsAccount : Entity<long>, IAggregateRoot
|
||||
public int Version { get; private set; } = 1;
|
||||
public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
|
||||
public DateTime? UpdatedAt { get; private set; }
|
||||
public Deleted Deleted { get; private set; } = new();
|
||||
public RowVersion RowVersion { get; private set; } = new(0);
|
||||
|
||||
private readonly List<PointsTransaction> _transactions = new();
|
||||
public IReadOnlyCollection<PointsTransaction> Transactions => _transactions.AsReadOnly();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Fengling.Member.Domain.Events.Member;
|
||||
using NetCorePal.Extensions.Domain;
|
||||
|
||||
namespace Fengling.Member.Domain.Aggregates.Users;
|
||||
|
||||
@ -23,6 +24,8 @@ public class MemberEntity : Entity<MemberId>, IAggregateRoot
|
||||
public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
|
||||
public DateTime? UpdatedAt { get; private set; }
|
||||
public int Version { get; private set; } = 1;
|
||||
public Deleted Deleted { get; private set; } = new();
|
||||
public RowVersion RowVersion { get; private set; } = new(0);
|
||||
|
||||
private readonly List<MemberTag> _tags = new();
|
||||
public IReadOnlyCollection<MemberTag> Tags => _tags.AsReadOnly();
|
||||
|
||||
@ -14,7 +14,8 @@ public class PointsAccountEntityTypeConfiguration : IEntityTypeConfiguration<Poi
|
||||
|
||||
builder.Property(p => p.Id)
|
||||
.HasColumnName("id")
|
||||
.UseIdentityColumn();
|
||||
.UseSnowFlakeValueGenerator()
|
||||
.HasComment("积分账户标识");
|
||||
|
||||
builder.Property(p => p.MemberId)
|
||||
.HasColumnName("user_id")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user