添加项目文件。
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
using GroupService.Domain.Enums;
|
||||
using GroupService.Domain.Events;
|
||||
using GroupService.Domain.ValueObjects;
|
||||
using IM.DomainCommons;
|
||||
|
||||
namespace GroupService.Domain.Entities
|
||||
{
|
||||
public class GroupJoinRequest : AggregateRootEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// 群聊编号
|
||||
///
|
||||
/// </summary>
|
||||
public Guid GroupId { get; private set; }
|
||||
public GroupProfile GroupProfile { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 申请人
|
||||
/// </summary>
|
||||
public Guid UserId { get; private set; }
|
||||
public UserProfile UserProfile { get; private set; }
|
||||
|
||||
public Guid? OperatorId { get; private set; }
|
||||
public string? OperatorName { get; private set; }
|
||||
public string? OperatorAvatar { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 申请状态(0:待管理员同意,1:已拒绝,2:已同意)
|
||||
/// </summary>
|
||||
public GroupJoinRequestState State { get; private set; } = GroupJoinRequestState.Pending;
|
||||
|
||||
/// <summary>
|
||||
/// 入群附言
|
||||
/// </summary>
|
||||
public string Description { get; private set; } = "申请入群";
|
||||
|
||||
private GroupJoinRequest() { }
|
||||
|
||||
public GroupJoinRequest(Guid userId, UserProfile user, Guid groupId, GroupProfile group, string? desc)
|
||||
{
|
||||
UserId = userId;
|
||||
GroupId = groupId;
|
||||
GroupProfile = group;
|
||||
UserProfile = user;
|
||||
if (desc is not null && desc.Length > 20)
|
||||
{
|
||||
throw new DomainException("入群描述不可超过20字符");
|
||||
}
|
||||
Description = desc ?? Description;
|
||||
}
|
||||
|
||||
public void Approve(Guid id, string nickName, string avatar)
|
||||
{
|
||||
if (State != GroupJoinRequestState.Pending) return;
|
||||
State = GroupJoinRequestState.Passed;
|
||||
OperatorAvatar = avatar;
|
||||
OperatorId = id;
|
||||
OperatorName = nickName;
|
||||
ModificationTime = DateTime.Now;
|
||||
AddDomainEvent(new GroupJoinRequestPassedDomainEvent(this));
|
||||
}
|
||||
|
||||
public void Decline(Guid id, string nickName, string avatar)
|
||||
{
|
||||
if (State != GroupJoinRequestState.Pending) return;
|
||||
State = GroupJoinRequestState.Declined;
|
||||
OperatorAvatar = avatar;
|
||||
OperatorId = id;
|
||||
OperatorName = nickName;
|
||||
ModificationTime = DateTime.Now;
|
||||
AddDomainEvent(new GroupJoinRequestDeclinedDomainEvent(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user