/// <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);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> RegisterByPassport([FromBody] DTOAPI_RegisterByPassport registerInfo)
        {
            try
            {
                var data = await this.services.RegisterPassport(registerInfo).ConfigureAwait(false);

                return(OkEx(data));
            }
            catch (Exception ex)
            {
                return(this.JsonToCamelCase(ex.Message, 50000, 50000, ex.Message));
            }
        }