Перепиливание под чистый DDD

This commit is contained in:
Халимов Рустам
2026-03-22 23:59:33 +03:00
parent 5da1a2f45d
commit 6e532b021d
302 changed files with 3595 additions and 3679 deletions
@@ -0,0 +1,43 @@
using Knot.Shared.Kernel;
using Knot.Modules.Auth.Domain;
namespace Knot.Modules.Auth.Infrastructure.Services;
public sealed class UserDisplayNameProvider : IUserDisplayNameProvider
{
private readonly IUserRepository _userRepository;
public UserDisplayNameProvider(IUserRepository userRepository)
{
_userRepository = userRepository;
}
public async Task<string> GetDisplayNameAsync(Guid userId, CancellationToken ct = default)
{
var user = await _userRepository.GetByIdAsync(userId, ct);
return user?.DisplayName ?? "User";
}
public async Task<UserInfo?> GetUserInfoAsync(Guid userId, CancellationToken ct = default)
{
var user = await _userRepository.GetByIdAsync(userId, ct);
if (user == null)
{
return null;
}
return new UserInfo(user.Id, user.Username, user.DisplayName, user.Avatar);
}
public async Task<IReadOnlyDictionary<Guid, UserInfo>> GetUsersInfoAsync(IEnumerable<Guid> userIds, CancellationToken ct = default)
{
var users = await _userRepository.GetByIdsAsync(userIds, ct);
var result = new System.Collections.Generic.Dictionary<Guid, UserInfo>();
foreach (var user in users)
{
result[user.Id] = new UserInfo(user.Id, user.Username, user.DisplayName, user.Avatar);
}
return result;
}
}