添加项目文件。
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
using FluentValidation;
|
||||
using MessageService.Domain.Enums;
|
||||
using MessageService.WebApi.Application.Message;
|
||||
|
||||
namespace MessageService.WebApi.Controllers.Message
|
||||
{
|
||||
public class MessageSendRequest
|
||||
{
|
||||
// 基础元数据
|
||||
public Guid ClientMsgId { get; init; }
|
||||
public Guid TargetId { get; init; }
|
||||
public ChatType ChatType { get; init; }
|
||||
public MessageType MsgType { get; init; }
|
||||
|
||||
// 业务属性
|
||||
public Guid? QuoteMessageId { get; init; }
|
||||
public Dictionary<string, string>? Ext { get; init; }
|
||||
|
||||
// 载荷数据(根据 MsgType 选择性填充)
|
||||
public string? Text { get; init; }
|
||||
public string? Url { get; init; }
|
||||
public int? Width { get; init; }
|
||||
public int? Height { get; init; }
|
||||
public string? Thumb { get; init; }
|
||||
public int? Duration { get; init; }
|
||||
|
||||
public SendMsgCommand ToCommand(Guid senderId)
|
||||
{
|
||||
return new SendMsgCommand(
|
||||
senderId,
|
||||
TargetId,
|
||||
ChatType,
|
||||
MsgType,
|
||||
ClientMsgId,
|
||||
QuoteMessageId,
|
||||
Ext,
|
||||
Text,
|
||||
Url,
|
||||
Width,
|
||||
Height,
|
||||
Thumb,
|
||||
Duration
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public class MessageSendRequestValidator : AbstractValidator<MessageSendRequest>
|
||||
{
|
||||
public MessageSendRequestValidator()
|
||||
{
|
||||
RuleFor(r => r.ClientMsgId)
|
||||
.NotNull()
|
||||
.NotEmpty();
|
||||
RuleFor(r => r.TargetId)
|
||||
.NotEmpty()
|
||||
.NotNull();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user