コード例 #1
0
 private boolean validateUserInfo(UserInfo loginInfo, JSONObject result) {
   if (StringUtil.isBlank(loginInfo.getUserName())
       || StringUtil.isBlank(loginInfo.getPassword())) {
     result.put("code", "400");
     result.put("message", "Username or password is null");
     return true;
   }
   return false;
 }
コード例 #2
0
  @RequestMapping(value = "/doRegister", produces = "application/json; charset=UTF-8")
  @ResponseBody
  public String doRegister(SignInUserInfo signInUserInfo) {
    JSONObject result = new JSONObject();
    try {

      if (validateUserInfo(signInUserInfo, result)) {
        return result.toJSONString();
      }
      signInUserInfo.setRoleType(Constants.USR.ROLE_TYPE_USER);
      signInUserInfo.setSts(Constants.USR.STR_VAL_A);
      iUserMaintainDao.addUser(signInUserInfo);
      if (StringUtil.isBlank(signInUserInfo.getUid())) {
        result.put("code", "500");
        result.put("message", "Failed to register user" + signInUserInfo.getUserName());
        return result.toJSONString();
      }

      result.put("code", "200");
      result.put("message", "register success");
    } catch (Exception e) {
      logger.error(
          "Failed to register the user[{}]",
          signInUserInfo.getUserName(),
          signInUserInfo.getPassword(),
          e);
      result.put("code", "500");
      result.put("message", "fatal error. please try it again.");
    }
    return result.toJSONString();
  }