Beispiel #1
0
  public JSONObject resetPwd(Map map) throws Exception {
    boolean isSuccess = true;
    String message = "";

    String userId = (String) map.get("userId");

    String email = (String) map.get("email");

    String verifyCode = (String) map.get("verifyCode");
    String verifyCodeInSession = (String) map.get("verifyCodeInSession");

    if (!verifyCode.equals(verifyCodeInSession)) {
      isSuccess = false;
      message = "验证码错误.";
    }

    List userList = null;
    if ((StringUtils.isNotEmpty(userId)) && (StringUtils.isNotEmpty(email))) {
      User paramUser = new User();
      paramUser.setUserId(userId);
      paramUser.setEmail(email);
      userList = selectByCriteria(paramUser);
    }
    if ((userList == null) || (userList.size() != 1)) {
      isSuccess = false;
      message = "用户名或邮箱错误.";
    }

    if (isSuccess) {
      User user = (User) userList.get(0);

      String newPassword = RandomStringUtils.random(6, true, true);

      String title = "密码重置";
      String content = user.getUserId() + ",您好:<br/>您的新密码是:" + newPassword;
      boolean rs = ServletHelp.sendEmail(email, title, content);
      if (rs) {
        User paramUser = new User();
        paramUser.setUserId(userId);
        paramUser.setPassword(MD5Utils.getMD5String(newPassword));
        update(paramUser);
      } else {
        isSuccess = false;
        message = "邮件发送失败.";
      }
    }

    JSONObject res = new JSONObject();
    res.put("success", Boolean.valueOf(isSuccess));
    res.put("message", message);
    return res;
  }
  public JSONArray selectAlbumForTree(String parentId) {
    JSONArray res = new JSONArray();

    Album paramAlbum = new Album();
    if (StringUtils.isNotEmpty(parentId)) {
      paramAlbum.setParentId(Integer.valueOf(Integer.parseInt(parentId)));
    }

    List albumList = new ArrayList();
    albumList = selectByCriteria(paramAlbum);
    res = getAlbumTreeFromList(albumList, parentId);
    return res;
  }