feat: 优化用户创建

This commit is contained in:
陈淳
2024-04-29 14:42:13 +08:00
parent cabdd55cf5
commit 547c7d1b6d
2 changed files with 12 additions and 6 deletions

View File

@@ -1,11 +1,8 @@
using System.Text.RegularExpressions;
using Mapster;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using TencentCloud.Ame.V20190916.Models;
using Volo.Abp.Authorization;
using Volo.Abp.Caching;
using Volo.Abp.Domain.Services;
@@ -109,7 +106,16 @@ namespace Yi.Framework.Rbac.Domain.Managers
throw new UserFriendlyException("密码需大于等于6位");
}
var isExist = await _repository.IsAnyAsync(x => x.UserName == userEntity.UserName || x.Phone == userEntity.Phone);
if (userEntity.Phone is not null)
{
if (await _repository.IsAnyAsync(x => x.Phone == userEntity.Phone))
{
throw new UserFriendlyException("用户手机号已重复");
}
}
var isExist = await _repository.IsAnyAsync(x => x.UserName == userEntity.UserName);
if (isExist)
{
throw new UserFriendlyException("用户已存在,创建失败");