public Task <int> UpdateAsync(string id, AccountInputDto inputDto) { var model = inputDto.MapTo <TAccount>(); model.Id = id; return(_repository.UpdateAsync(model)); }
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>()); }