Skip to content

Commit

Permalink
Merge pull request #121 from Zzzzjle/dev
Browse files Browse the repository at this point in the history
breakchange: 将 AddDomainEvent 方法的访问修饰符从 public 修改为 protected
  • Loading branch information
witskeeper authored Dec 11, 2024
2 parents 4d4580d + 2d31af7 commit 70f03da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Domain.Abstractions/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public abstract class Entity

public override string ToString() => $"[Entity: {GetType().Name}] Keys = {string.Join(",", GetKeys())}";

private readonly List<IDomainEvent> _domainEvents = new();
private readonly List<IDomainEvent> _domainEvents = [];
public IReadOnlyList<IDomainEvent> GetDomainEvents() => _domainEvents.AsReadOnly();

public void AddDomainEvent(IDomainEvent eventItem)
protected void AddDomainEvent(IDomainEvent eventItem)
{
_domainEvents.Add(eventItem);
}
Expand All @@ -35,7 +35,7 @@ public abstract class Entity<TKey> : Entity where TKey : notnull
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
public virtual TKey Id { get; protected set; }
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
public override object[] GetKeys() => new object[] { Id };
public override object[] GetKeys() => [Id];

public override bool Equals(object? obj)
{
Expand Down
14 changes: 13 additions & 1 deletion src/NetCorePal.Extensions.Dto/PagedData.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace NetCorePal.Extensions.Dto;
using System.Text.Json.Serialization;

namespace NetCorePal.Extensions.Dto;

/// <summary>
/// 分页数据模型
Expand All @@ -13,25 +15,35 @@ public class PagedData<T>
/// <param name="total">总数据条数</param>
/// <param name="pageIndex">当前页码,从1开始</param>
/// <param name="pageSize">每页条数</param>
[JsonConstructor]
public PagedData(IEnumerable<T> items, int total, int pageIndex, int pageSize)
{
Items = items;
Total = total;
PageIndex = pageIndex;
PageSize = pageSize;
}

public PagedData()
{
Items = [];
}

/// <summary>
/// 分页数据
/// </summary>
public IEnumerable<T> Items { get; private set; }

/// <summary>
/// 数据总数
/// </summary>
public int Total { get; private set; }

/// <summary>
/// 当前页码,从1开始
/// </summary>
public int PageIndex { get; private set; }

/// <summary>
/// 每页数据条数
/// </summary>
Expand Down

0 comments on commit 70f03da

Please sign in to comment.