/// <summary> /// /// </summary> /// <param name="registerInfo"></param> /// <returns></returns> public async Task <long> RegisterPassport(DTOAPI_RegisterByPassport registerInfo) { if (!AccountValidator.bValidPassport(registerInfo.passport)) { throw new Exception("用户名格式不正确"); } if (!AccountValidator.bValidPassword(registerInfo.password)) { throw new Exception("密码格式错误"); } var account = this.accesser.Get(passport: registerInfo.passport).Item1; if (account != null) { throw new Exception("用户名已存在"); } long newId = this.IDGenerator.GetNewID <Account>(); await this.publishEndpoint.Publish(new RegisterAccountByPassportCommand { id = newId, passport = registerInfo.passport, password = registerInfo.password }); return(newId); }