Files
IM_NEW/MessageService.WebApi/Controllers/Message/MessageSendRequest.cs
T
2026-05-09 17:06:30 +08:00

60 lines
1.7 KiB
C#

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();
}
}
}