为了账号安全,请及时绑定邮箱和手机立即绑定

register中userModel,userDO获取不到id,都获取不到id

@Override

@Transactional

public void register(UserModel userModel) throws BusinessException {

if (userModel == null) {

throw new BusinessException(EmBusinessError.PARAMETER_VALIDATION_ERROR);

}

if (StringUtils.isEmpty(userModel.getName()) || userModel.getGender() == null || userModel.getAge() == null

|| StringUtils.isEmpty(userModel.getTelphone())) {

throw new BusinessException(EmBusinessError.PARAMETER_VALIDATION_ERROR);

}

// 实现Model -> DataObject方法

UserDO userDO = convertFromModel(userModel);

userModel.setId(userDO.getId());

try {

userDOMapper.insertSelective(userDO);

} catch (DuplicateKeyException ex) {

throw new BusinessException(EmBusinessError.PARAMETER_VALIDATION_ERROR, "手机号已重复注册");

}

UserPasswordDO userPasswordDO = convertPasswordFromModel(userModel);

userPasswordDOMapper.insertSelective(userPasswordDO);

return;

}


private UserDO convertFromModel(UserModel userModel) {

if (userModel == null) {

return null;

}

UserDO userDO = new UserDO();

BeanUtils.copyProperties(userModel, userDO);

return userDO;

}


private UserPasswordDO convertPasswordFromModel(UserModel userModel) {

if (userModel == null) {

return null;

}


UserPasswordDO userPasswordDO = new UserPasswordDO();

userPasswordDO.setEncrptPassword(userModel.getEncrptPassword());

userPasswordDO.setUserId(userModel.getId());

return userPasswordDO;

}


正在回答

1 回答

贴下错误信息啊 老铁

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

register中userModel,userDO获取不到id,都获取不到id

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信