feat: 注册用户时支持传入头像参数

This commit is contained in:
chenchun
2025-08-29 14:11:50 +08:00
parent c5b6b33d8e
commit 7905911624

View File

@@ -37,11 +37,14 @@ namespace Yi.Framework.Rbac.Domain.Managers
private UserManager _userManager;
private ISqlSugarRepository<RoleAggregateRoot> _roleRepository;
private RefreshJwtOptions _refreshJwtOptions;
/// <summary>
/// 缓存前缀
/// </summary>
private string CacheKeyPrefix => LazyServiceProvider.LazyGetRequiredService<IOptions<AbpDistributedCacheOptions>>()
private string CacheKeyPrefix => LazyServiceProvider
.LazyGetRequiredService<IOptions<AbpDistributedCacheOptions>>()
.Value.KeyPrefix;
public IDistributedLockProvider DistributedLock =>
LazyServiceProvider.LazyGetService<IDistributedLockProvider>();
@@ -304,7 +307,9 @@ namespace Yi.Framework.Rbac.Domain.Managers
}
//制作幂等
await using (var handle = await DistributedLock.TryAcquireLockAsync($"{CacheKeyPrefix}Register:Lock:{userName}", TimeSpan.FromSeconds(60)))
await using (var handle =
await DistributedLock.TryAcquireLockAsync($"{CacheKeyPrefix}Register:Lock:{userName}",
TimeSpan.FromSeconds(60)))
{
if (handle is null)
{
@@ -312,12 +317,13 @@ namespace Yi.Framework.Rbac.Domain.Managers
}
var userUpName = userName.ToUpper();
if (await _userManager._repository._DbQueryable.Where(x => x.UserName.ToUpper() == userUpName).AnyAsync())
if (await _userManager._repository._DbQueryable.Where(x => x.UserName.ToUpper() == userUpName)
.AnyAsync())
{
throw new UserFriendlyException($"{userName}用户已注册");
}
var user = new UserAggregateRoot(userName, password, phone, email, nick);
var user = new UserAggregateRoot(userName, password, phone, email, nick, icon);
var userId = await _userManager.CreateAsync(user);
await _userManager.SetDefautRoleAsync(user.Id);
return userId;