private void updateUserCommon(
     String userid,
     String name,
     String phone,
     String boatcard,
     Integer cansearchbyphone,
     Integer hideroomtelephone,
     Integer cansearch,
     String realname,
     String room,
     Integer age) {
   User u = null;
   if (!StringUtils.isBlank(userid)) {
     u = userService.findById(Integer.valueOf(userid));
   }
   if (u != null) {
     if (StringUtils.isNotBlank(name)) {
       u.setName(name);
     }
     if (StringUtils.isNotBlank(phone)) {
       u.setPhone(phone);
     }
     if (StringUtils.isNotBlank(boatcard)) {
       u.setBoatcard(boatcard);
     }
     if (cansearchbyphone != null) {
       u.setCansearchbyphone(cansearchbyphone);
     }
     if (age != null) {
       u.setAge(age);
     }
     if (cansearch != null) {
       u.setCansearch(cansearch);
     }
     if (hideroomtelephone != null) {
       u.setHideroomtelephone(hideroomtelephone);
     }
     if (StringUtils.isNotBlank(realname)) {
       u.setRealname(realname);
       if (StringUtils.isBlank(u.getPinyinname())) {
         String pinyin = Utils.getPinYin(realname);
         if (StringUtils.isNotBlank(pinyin)) {
           u.setPinyinname(pinyin);
         }
         if (StringUtils.isBlank(u.getName())) {
           u.setName(pinyin);
         }
       }
     }
     if (StringUtils.isNotBlank(room)) {
       u.setRoomtelephone(room);
     }
     userService.saveOrUpdate(u);
   }
 }
 @Override
 public UserResult register(UserEntity user) {
   UserResult ur = new UserResult();
   try {
     if (user != null) {
       String loginName = user.getLoginname();
       // 检查登录名是否重复
       boolean res = chekLoginName(loginName);
       if (!res) {
         User usr = new User();
         String pwd = "";
         if (user.getPwd() != null) {
           pwd = MD5Util.md5(user.getPwd());
           usr.setPlainPassword(user.getPwd());
         }
         usr.setCreateDate(new Date());
         usr.setLoginname(loginName);
         usr.setPwd(pwd);
         usr.setName(user.getName());
         usr.setPhone(user.getPhone());
         usr.setStatus(3);
         usr.setLat(user.getLat());
         usr.setLon(user.getLon());
         usr.setParseaddress(user.getParseaddress());
         usr.setUsertype(user.getUsertype());
         this.saveOrUpdate(usr);
         User userinfo = userService.findByLoginName(loginName);
         if (userinfo != null) {
           user.setId(userinfo.getId().toString());
         }
         user.setPwd("");
         user.setState(Constants.DEFAULT_STATE);
         user.setCity(Constants.DEFAULT_CITY);
         user.setSex(Constants.DEFAULT_SEX_VALUE);
         ur.setUser(user);
         ur.setErrorCode(0);
         ur.setErrorMessage("");
       } else {
         ValidationError ve = ValidationError.LOGINNAMEREPEAT;
         int errorCode = ve.getErrorCode();
         String message = Utils.getErrorMessage(ve);
         ur.setErrorCode(errorCode);
         ur.setErrorMessage(message);
       }
     }
   } catch (Exception ex) {
     ValidationError er = ValidationError.SYSTEM_ERROR;
     int errorCode = er.getErrorCode();
     ur.setErrorCode(errorCode);
     ur.setErrorMessage("系统错误");
     logger.error(ex.getMessage());
   }
   return ur;
 }