@Override
 public UserResult getUserByName(String loginname) {
   UserResult ur = new UserResult();
   try {
     if (!StringUtils.isBlank(loginname)) {
       User user = userService.findByLoginName(loginname);
       if (user != null) {
         if (user.getUsertype() == 2) {
           BusinessUserDetail businessUserdetail =
               businessUserDetailService.findByUserId(user.getId());
           BusinessUserEntity businessUserVO =
               ConvertHelper.toBusinessUserEntity(user, businessUserdetail);
           ur.setBusinessUser(businessUserVO);
         } else {
           UserDetail userdetail = userDetailService.findByUserId(user.getId());
           UserEntity userVO = ConvertHelper.toUserEntity(user, userdetail);
           ur.setUser(userVO);
         }
       }
     }
     ur.setErrorCode(0);
     ur.setErrorMessage("");
   } catch (Exception ex) {
     ValidationError ve = ValidationError.SYSTEM_ERROR;
     ur.setErrorCode(ve.getErrorCode());
     ur.setErrorMessage("系统错误");
     logger.error(ex.getMessage());
   }
   return ur;
 }
  /** 登录服务 return UserResult */
  @Override
  public UserResult login(UserEntity user) {
    UserResult ur = new UserResult();
    try {
      String username = user.getLoginname();
      String password = MD5Util.md5(user.getPwd());
      User u = null;
      u = userService.findByLoginNameAndPwd(username, password);
      if (u == null) {
        ValidationError er = ValidationError.LOGINFAILE;
        int errorCode = er.getErrorCode();
        String errorMessage = er.getErrorMessage();
        ur.setErrorCode(errorCode);
        ur.setErrorMessage(errorMessage);

      } else {
        if (u.getUsertype() == 2) {
          BusinessUserDetail businessUserdetail = businessUserDetailService.findByUserId(u.getId());
          BusinessUserEntity businessUserVO =
              ConvertHelper.toBusinessUserEntity(u, businessUserdetail);
          ur.setBusinessUser(businessUserVO);
        } else {
          UserDetail userdetail = userDetailService.findByUserId(u.getId());
          UserEntity userVO = ConvertHelper.toUserEntity(u, userdetail);
          ur.setUser(userVO);
        }
        ur.setErrorCode(0);
        ur.setErrorMessage("");
      }
    } catch (Exception ex) {
      ValidationError er = ValidationError.SYSTEM_ERROR;
      ur.setErrorCode(er.getErrorCode());
      ur.setErrorMessage("系统错误");
      logger.error(ex.getMessage());
    }
    return ur;
  }