public String editAccount() { boolean isSuccess = true; String result = "0"; try { account = (Account) accountManagerService.queryAccountByAccountId(id); String roleTmp = account.getRoles(); if (roleTmp != null && roleTmp.length() != 0) { String[] roleStrings = roleTmp.split(","); seledRoles = new ArrayList<String>(Arrays.asList(roleStrings)); } orgLevAndIdNames = accountManagerService.getOrgLevAndIdNamesByAccountId(id); allowedRoles = accountManagerService.getAllowedRolesByAccountId(); } 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; } }
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: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; } }
/** * 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: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; } }