添加项目文件。

This commit is contained in:
2026-05-09 17:06:30 +08:00
parent c60f5fe117
commit 720ef957d4
378 changed files with 14843 additions and 0 deletions
@@ -0,0 +1,35 @@
using ContactService.Domain;
using ContactService.Infrastructure;
using IM.Commons.IntegrationEvents;
using MassTransit;
namespace ContactService.WebApi.Application.EventHandler
{
public class UserProfileUpdateHandler : IConsumer<UserProfileUpdateEvent>
{
private readonly ContactDbContext contactDb;
private readonly IFriendReposity reposity;
public UserProfileUpdateHandler(ContactDbContext contactDb, IFriendReposity reposity)
{
this.contactDb = contactDb;
this.reposity = reposity;
}
public async Task Consume(ConsumeContext<UserProfileUpdateEvent> context)
{
var @event = context.Message;
var friends = await reposity.FindByTargetAsync(@event.UserId);
foreach (var friend in friends)
{
friend.UpdateUserInfo(
new Domain.ValueObjects.UserProfile(
@event.UserId, @event.Avatar, @event.NickName));
}
await contactDb.SaveChangesAsync();
}
}
}