Пример #1
0
  // result:2--不存在;0:成功;-1:异常
  public String updateAccountPassword() {
    int resultForLog = AlarmConstants.RESULT_SUC;
    String message = "";
    boolean isSuccess = true;
    String result = "0";
    int resultForDel = -1;
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpSession httpSession = request.getSession();
    Session session = (Session) httpSession.getAttribute("session");
    if (session != null) {
      id = session.getId();
      try {
        if (!password.equals(rePassword.trim())) {
          result = "3";
        } else {
          result =
              String.valueOf(
                  accountManagerService.updateAccountPassword(
                      id, oldPasswd.trim(), password.trim()));
        }
      } catch (Exception ex) {
        log.error(ex.getMessage(), ex);
        message = "数据库异常";
        resultForLog = AlarmConstants.RESULT_FAIL;
      }
    }
    operationLogService.createOperationLog("updateAccountPassword", id, resultForLog, message);

    StringBuffer msg = new StringBuffer("修改帐号密码").append(id);
    switch (Integer.parseInt(result)) {
      case 2:
        msg.append("失败,帐号密码已经不存在。");
        isSuccess = false;
        resultForDel = 0;
        break;
      case -1:
        msg.append("失败,数据库异常!");
        isSuccess = false;
        resultForDel = 0;
        break;
      case 3:
        msg.append("失败,两次密码输入不一致!");
        isSuccess = false;
        resultForDel = 0;
        break;
      default:
        msg.append("成功。");
        resultForDel = 1;
        isSuccess = true;
        break;
    }
    ajaxObject = new AjaxObject(resultForDel, msg.toString());
    if (isSuccess) {
      return SUCCESS;
    } else {
      return ERROR;
    }
  }
Пример #2
0
  // result:2--不存在;0:成功;-1:异常
  public String resetAccountPassword() {
    int resultForLog = AlarmConstants.RESULT_SUC;
    String message = "";
    boolean isSuccess = true;
    String result = null;
    int resultForDel = -1;

    try {
      result = String.valueOf(accountManagerService.resetAccountPassword(id));
    } catch (Exception ex) {
      log.error(ex.getMessage(), ex);
      result = "-1";
      message = "数据库异常";
      resultForLog = AlarmConstants.RESULT_FAIL;
    }
    operationLogService.createOperationLog("resetAccountPassword", id, resultForLog, message);

    StringBuffer msg = new StringBuffer("重置密码").append(id);
    switch (Integer.parseInt(result)) {
      case 2:
        msg.append("失败,帐号已经不存在。");
        resultForDel = 0;
        isSuccess = false;
        break;
      case -1:
        msg.append("失败,数据库异常!");
        isSuccess = false;
        resultForDel = 0;
        break;
      default:
        msg.append("成功。");
        resultForDel = 1;
        isSuccess = true;
        break;
    }
    // commonBean = new CommonBean(result, msg.toString());
    ajaxObject = new AjaxObject(resultForDel, msg.toString());
    if (isSuccess) {
      return SUCCESS;
    } else {
      return ERROR;
    }
  }
Пример #3
0
  // result:2--不存在;0:成功;-1:异常
  public String updateAccount() {
    int resultForLog = AlarmConstants.RESULT_SUC;
    String message = "";
    boolean isSuccess = true;
    String result = null;

    String homeAddress = account.getHomeAddress();
    String homeTel = account.getHomeTel();
    String id = account.getId();
    String mail = account.getMail();
    String offTel = account.getOffTel();
    String phone = account.getPhone();
    String position = account.getPosition();
    String positionDesc = account.getPositionDesc();
    String remark = account.getRemark();
    String userId = account.getUserId();
    String userName = account.getUserName();

    account.setHomeAddress(homeAddress.trim());
    account.setHomeTel(homeTel.trim());
    account.setId(id.trim());
    account.setMail(mail.trim());
    account.setOffTel(offTel.trim());
    account.setPhone(phone.trim());
    account.setPosition(position.trim());
    account.setPositionDesc(positionDesc.trim());
    account.setRemark(remark.trim());
    account.setUserId(userId.trim());
    account.setUserName(userName.trim());

    account.setType(1); //
    account.setPassword(account.getId());
    account.setRoles(transListToString(seledRoles));

    try {
      result = String.valueOf(accountManagerService.updateAccount(account));
      orgLevAndIdNames = accountManagerService.getOrgLevAndIdNamesByAccountId(id.trim());
      allowedRoles = accountManagerService.getAllowedRolesByAccountId();
    } catch (Exception ex) {
      log.error(ex.getMessage(), ex);
      result = "-1";
      message = "数据库异常";
      resultForLog = AlarmConstants.RESULT_FAIL;
    }
    operationLogService.createOperationLog("updateAccount", account.getId(), resultForLog, message);

    StringBuffer msg = new StringBuffer("修改帐号").append(account.getId());
    switch (Integer.parseInt(result)) {
      case 2:
        msg.append("失败,帐号已经不存在。");
        isSuccess = false;
        break;
      case -1:
        msg.append("失败,数据库异常!");
        isSuccess = false;
        break;
      default:
        msg.append("成功。");
        isSuccess = true;
        break;
    }
    commonBean = new CommonBean(result, msg.toString());
    if (isSuccess) {
      return SUCCESS;
    } else {
      return ERROR;
    }
  }