Esempio n. 1
0
        public Task <int> UpdateAsync(string id, AccountInputDto inputDto)
        {
            var model = inputDto.MapTo <TAccount>();

            model.Id = id;
            return(_repository.UpdateAsync(model));
        }
Esempio n. 2
0
        public async Task <AccountDto> CreateAsync(AccountInputDto inputDto)
        {
            if (await _repository.ExistsAccountAsync(inputDto.Account))
            {
                throw new BusiException("登录帐号已存在");
            }
            var model = inputDto.MapTo <TAccount>();

            model.Id           = IdentityHelper.Guid32;
            model.PasswordSalt = IdentityHelper.Guid16;
            model.Password     = $"{model.Password},{model.PasswordSalt}".Md5();
            model.CreateTime   = Clock.Now;
            var result = await _repository.InsertAsync(model);

            if (result <= 0)
            {
                throw new BusiException("创建账户失败");
            }
            return(model.MapTo <AccountDto>());
        }