慕后端8268368
2019-07-06 20:03
求帮忙解答,谢谢
进行用户注册,能够成功的注册,但是Nick列显示的总是false。以下是我的代码:
//service代码 @Override @Transactional//事务提交,防止出错 public void register(UserModel userModel) throws BusinessException { if(userModel==null){ throw new BusinessException(EmBussinessError.PARAMETER_VALIDATION_ERROR,"对象为空"); } if(StringUtils.isEmpty(userModel.getNick())||userModel.getGender()==null|| userModel.getAge()==null||StringUtils.isEmpty(userModel.getTelphone())){ throw new BusinessException(EmBussinessError.PARAMETER_VALIDATION_ERROR,"入参不合法"); } UserDO userDO=convertFromUserModel(userModel);//实现model到dataobject方法; userDOMapper.insertSelective(userDO); userModel.setId(userDO.getId()); UserPasswordDO userPasswordDO=convertPasswprdFromModel(userModel);//实现model到dataobject userPasswordDOMapper.insertSelective(userPasswordDO); return; } //将model转化为userDo public UserDO convertFromUserModel(UserModel userModel){ if(userModel==null){ return null; } UserDO userDO=new UserDO(); BeanUtils.copyProperties(userModel,userDO); return userDO; } //获取password信息 private UserPasswordDO convertPasswprdFromModel(UserModel userModel){ if(userModel==null){ return null; } UserPasswordDO userPasswordDO=new UserPasswordDO(); userPasswordDO.setEncrptpassword(userModel.getEncrptpassword()); userPasswordDO.setUserId(userModel.getId()); return userPasswordDO; } //controller代码 //用户注册接口 @RequestMapping(value = "/register",method = {RequestMethod.POST},consumes = {CONTENT_TYPE_FORMED})//获得个头图片的映射 @ResponseBody public CommonReturnType register(@RequestParam(name="telphone")String telphone, @RequestParam(name="otpCode")String otpCode, @RequestParam(name="nick")String nick, @RequestParam(name="gender")String gender, @RequestParam(name="age")Integer age, @RequestParam(name="password")String password) throws BusinessException, UnsupportedEncodingException, NoSuchAlgorithmException { //验证手机号和对应的otpcode相符合 String insessionOtpCode= (String) this.httpServletRequest.getSession().getAttribute(telphone); if(!StringUtils.equals(otpCode,insessionOtpCode)){ throw new BusinessException(EmBussinessError.PARAMETER_VALIDATION_ERROR,"短信验证码不正确"); } //用户的注册流程 UserModel userModel=new UserModel(); userModel.setNick(nick); userModel.setGender(gender); userModel.setAge(age); userModel.setTelphone(telphone); userModel.setEncrptpassword(this.EncodeByMd5(password)); userService.register(userModel); return CommonReturnType.create(null); }
描述清楚一点
SpringBoot构建电商基础秒杀项目
49065 学习 · 954 问题
相似问题