public String editAccountPassword() { boolean isSuccess = true; String result = "0"; HttpServletRequest request = ServletActionContext.getRequest(); HttpSession httpSession = request.getSession(); Session session = (Session) httpSession.getAttribute("session"); if (session != null) { try { Account account = (Account) accountManagerService.queryAccountByAccountId(session.getId()); if (account != null) oldpassword = account.getPassword(); } catch (Exception ex) { log.error(ex.getMessage(), ex); result = "-1"; } } StringBuffer msg = new StringBuffer("查询账号"); switch (Integer.parseInt(result)) { 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; } }
// 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; } }
/** * result:0:成功;-1:异常 * * @return SUCCESS */ public String entryCreateAccount() { boolean isSuccess = true; String result = "0"; HttpServletRequest request = ServletActionContext.getRequest(); HttpSession httpSession = request.getSession(); Session session = (Session) httpSession.getAttribute("session"); if (session != null) { try { account = new Account(); account.setBirthday(null); seledRoles = new ArrayList<String>(); orgLevAndIdNames = accountManagerService.getOrgLevAndIdNamesByAccountId(session.getId()); allowedRoles = accountManagerService.getAllowedRolesByAccountId(); } catch (Exception ex) { log.error(ex.getMessage(), ex); result = "-1"; } } else result = "-2"; StringBuffer msg = new StringBuffer("查询机构和角色"); switch (Integer.parseInt(result)) { case -2: msg.append("失败,无Session对象!"); 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; } }
/** * result:0:成功;-1:异常 * * @return SUCCESS */ public String queryAccountsByAccountId() { int resultForLog = AlarmConstants.RESULT_SUC; String message = ""; boolean isSuccess = true; String result = "0"; HttpServletRequest request = ServletActionContext.getRequest(); HttpSession httpSession = request.getSession(); Session session = (Session) httpSession.getAttribute("session"); if (session != null) { try { accounts = accountManagerService.queryAccountsByAccountId(session.getId()); } catch (Exception ex) { log.error(ex.getMessage(), ex); result = "-1"; message = "数据库异常"; resultForLog = AlarmConstants.RESULT_FAIL; } } // operationLogService.createOperationLog("queryAccountsByAccountId", // "", // resultForLog, message); StringBuffer msg = new StringBuffer("查询帐号"); switch (Integer.parseInt(result)) { 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; } }
// result:1--已存在;0:成功;-1:异常 public String createAccount() { int resultForLog = AlarmConstants.RESULT_SUC; String message = ""; boolean isSuccess = true; String result = null; HttpServletRequest request = ServletActionContext.getRequest(); HttpSession httpSession = request.getSession(); Session session = (Session) httpSession.getAttribute("session"); 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(id.trim()); account.setRoles(transListToString(seledRoles)); try { result = String.valueOf(accountManagerService.createAccount(account)); orgLevAndIdNames = accountManagerService.getOrgLevAndIdNamesByAccountId(session.getId()); allowedRoles = accountManagerService.getAllowedRolesByAccountId(); } catch (Exception ex) { log.error(ex.getMessage(), ex); result = "-1"; message = "数据库异常"; resultForLog = AlarmConstants.RESULT_FAIL; } operationLogService.createOperationLog("createAccount", account.getId(), resultForLog, message); StringBuffer msg = new StringBuffer("创建帐号").append(account.getId()); switch (Integer.parseInt(result)) { case 1: 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; } }