This commit is contained in:
2026-08-31 14:42:22 +08:00
72 changed files with 2479 additions and 168 deletions
@@ -1,4 +1,6 @@
using MessageService.WebApi.Application.Conversation;
using IM.ASPNETCore;
using MessageService.Infrastructure;
using MessageService.WebApi.Application.Conversation;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System.Security.Claims;
@@ -30,5 +32,13 @@ namespace MessageService.WebApi.Controllers.Conversation
return Ok(await service.GetByIdAsync(id, Guid.Parse(userId)));
}
[HttpPost]
[UnitOfWork(typeof(MessageDbContext))]
public async Task<IActionResult> MarkRead([FromQuery] Guid conversationId)
{
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
return Ok(await service.MarkAsReadAsync(conversationId, Guid.Parse(userId)));
}
}
}
@@ -54,6 +54,19 @@ namespace MessageService.WebApi.Controllers.Message
RuleFor(r => r.TargetId)
.NotEmpty()
.NotNull();
// 文本消息:text 必填
When(r => r.MsgType == MessageType.Text, () =>
{
RuleFor(r => r.Text).NotEmpty().WithMessage("文本消息的 text 字段不能为空");
});
// 图片/视频/语音消息:url 必填
When(r => r.MsgType == MessageType.Image || r.MsgType == MessageType.Video
|| r.MsgType == MessageType.Voice || r.MsgType == MessageType.File, () =>
{
RuleFor(r => r.Url).NotEmpty().WithMessage("媒体消息的 url 字段不能为空");
});
}
}
}