feat: 手机号不是必填
parent
f2deb6ccd8
commit
a2dece29c8
|
|
@ -63,7 +63,7 @@ public class UserService : IUserService
|
||||||
public async Task CreateUser(User input)
|
public async Task CreateUser(User input)
|
||||||
{
|
{
|
||||||
await using var _userPointManagementDbContext = await _dbContextFactory.CreateDbContextAsync();
|
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("手机号不可重复!");
|
throw new ArgumentException("手机号不可重复!");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@
|
||||||
<FormItem Label="姓名" Rules=@(new FormValidationRule[] { new FormValidationRule { Required = true, Message = "名称不可为空!" }, new FormValidationRule() { Len = 50, Message = "名称上限50字" } })>
|
<FormItem Label="姓名" Rules=@(new FormValidationRule[] { new FormValidationRule { Required = true, Message = "名称不可为空!" }, new FormValidationRule() { Len = 50, Message = "名称上限50字" } })>
|
||||||
<Input @bind-Value="@context.Name"/>
|
<Input @bind-Value="@context.Name"/>
|
||||||
</FormItem>
|
</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"/>
|
<Input @bind-Value="@context.Mobile"/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue