添加项目文件。
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
using ContactService.Domain.Events;
|
||||
using IM.DomainCommons;
|
||||
|
||||
namespace ContactService.Domain.Entities
|
||||
{
|
||||
public class FriendRequest : AggregateRootEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 申请人
|
||||
/// </summary>
|
||||
public Guid OwnerId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 被申请人
|
||||
/// </summary>
|
||||
public Guid TargetId { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 申请附言
|
||||
/// </summary>
|
||||
public string Description { get; private set; } = "申请添加好友";
|
||||
|
||||
/// <summary>
|
||||
/// 申请状态(0:待通过,1:拒绝,2:同意,3:拉黑)
|
||||
/// </summary>
|
||||
public FriendRequestStatus State { get; private set; } = FriendRequestStatus.Pending;
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string? RemarkName { get; private set; }
|
||||
|
||||
private FriendRequest() { }
|
||||
|
||||
public FriendRequest(Guid ownerId, Guid targetId, string? description, string? remarkName)
|
||||
{
|
||||
OwnerId = ownerId;
|
||||
TargetId = targetId;
|
||||
Description = description ?? Description;
|
||||
RemarkName = remarkName;
|
||||
AddDomainEvent(new FriendRequestCreatedDomainEvent(this));
|
||||
}
|
||||
public void Accept(string remarkName)
|
||||
{
|
||||
if (State != FriendRequestStatus.Pending)
|
||||
{
|
||||
throw new DomainException("只能处理待处理的好友请求");
|
||||
}
|
||||
State = FriendRequestStatus.Passed;
|
||||
AddDomainEvent(new FriendRequestStateUpdateDomainEvent(this,remarkName));
|
||||
}
|
||||
|
||||
public void Reject()
|
||||
{
|
||||
if (State != FriendRequestStatus.Pending)
|
||||
{
|
||||
throw new DomainException("只能处理待处理的好友请求");
|
||||
}
|
||||
State = FriendRequestStatus.Declined;
|
||||
AddDomainEvent(new FriendRequestStateUpdateDomainEvent(this));
|
||||
}
|
||||
public void Block()
|
||||
{
|
||||
if (State != FriendRequestStatus.Pending)
|
||||
{
|
||||
throw new DomainException("只能处理待处理的好友请求");
|
||||
}
|
||||
State = FriendRequestStatus.Blocked;
|
||||
AddDomainEvent(new FriendRequestStateUpdateDomainEvent(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user