feat: 手机号不是必填

develop
Yosheng 2023-07-30 21:29:05 +08:00
parent f2deb6ccd8
commit a2dece29c8
2 changed files with 2 additions and 2 deletions

View File

@ -63,7 +63,7 @@ public class UserService : IUserService
public async Task CreateUser(User input)
{
await using var _userPointManagementDbContext = await _dbContextFactory.CreateDbContextAsync();
if (_userPointManagementDbContext.Users.Any(x => x.Mobile == input.Mobile))
if (!string.IsNullOrWhiteSpace(input.Mobile) && _userPointManagementDbContext.Users.Any(x => x.Mobile == input.Mobile))
{
throw new ArgumentException("手机号不可重复!");
}

View File

@ -92,7 +92,7 @@
<FormItem Label="姓名" Rules=@(new FormValidationRule[] { new FormValidationRule { Required = true, Message = "名称不可为空!" }, new FormValidationRule() { Len = 50, Message = "名称上限50字" } })>
<Input @bind-Value="@context.Name"/>
</FormItem>
<FormItem Label="手机号" Rules="@(new FormValidationRule[] { new FormValidationRule { Type = FormFieldType.Regexp, Pattern = @"^1\d{10}$", Message = "请输入正确手机号", Required = true } })">
<FormItem Label="手机号" Rules="@(new FormValidationRule[] { new FormValidationRule { Type = FormFieldType.Regexp, Pattern = @"^1\d{10}$", Message = "请输入正确手机号", Required = false } })">
<Input @bind-Value="@context.Mobile"/>
</FormItem>
</Form>