fix: NullReferenceException
This commit is contained in:
parent
17b08e7834
commit
e1d4956d91
|
|
@ -14,7 +14,12 @@ public partial class MongoRepository
|
|||
public User? GetUserByPhone(string phone)
|
||||
{
|
||||
string phoneSecond = string.Empty;
|
||||
if (phone.Length >= 4 && phone.Substring(0, 3) != "+86")
|
||||
// 如果电话号码长度小于 4,直接返回 null
|
||||
if (phone?.Length < 4)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (phone.Substring(0, 3) != "+86")
|
||||
{
|
||||
phoneSecond = $"+86{phone}";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue