using Dpz.Core.Public.ViewModel.RequestEvent;
namespace Dpz.Core.Service.Event;
/// <summary>
/// 已过时:请使用 AddCommentCountHandler 和 RabbitMQ 消息队列替代。
/// 原 MediatR 同步处理模式已迁移到异步消息队列,提供更好的性能和可靠性。
/// </summary>
[Obsolete(
"请使用 Web.Jobs 项目中的 AddCommentCountHandler 替代。MediatR 同步处理已迁移到 RabbitMQ 异步消息队列。",
false
)]
public class AddCommentCountEvent(IRepository<Video> repository, ICommentService service)
: IRequestHandler<AddCommentCountRequest>
{
public async Task Handle(AddCommentCountRequest request, CancellationToken cancellationToken)
{
if (request.CommentType != CommentNode.Video)
{
return;
}
var count = await service.GetCommentCountAsync(request.CommentType, request.Relation);
var update = Builders<Video>.Update.Set(x => x.CommentCount, count + 1);
await repository.UpdateAsync(x => x.Id == request.Relation, update, cancellationToken);
}
}
评论加载中...