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; } }
/** * 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 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; } }