コード例 #1
0
 public void query() throws ServletException, IOException {
   HttpServletRequest request = Struts2Utils.getRequest();
   List<TbBaseUserInfo> list = null;
   List<PropertyFilter> filters =
       HibernateWebUtils.buildPropertyFilters(Struts2Utils.getRequest());
   GridServerHandler gridServerHandler =
       new GridServerHandler(Struts2Utils.getRequest(), Struts2Utils.getResponse());
   // 角色查询
   String vcRoleNo = request.getParameter("role_search");
   if (vcRoleNo != null && !vcRoleNo.equals("")) {
     String vcUserNos = baseUserInfoManager.getUserIdByRoleId(vcRoleNo);
     String[] vun = vcUserNos.split(",");
     filters.add(new PropertyFilter("id", vun, MatchType.IN));
   }
   page.setOrderBy("id");
   page.setOrder("desc");
   page.setPageSize(gridServerHandler.getPageSize());
   page.setPageNo(gridServerHandler.getPageInfo().getPageNum());
   page = baseUserInfoManager.search(page, filters);
   int totalRowNum = gridServerHandler.getTotalRowNum();
   if (totalRowNum < 1) {
     totalRowNum = page.getTotalCount();
     gridServerHandler.setTotalRowNum(totalRowNum);
   }
   list = page.getResult();
   gridServerHandler.setData(this.formatViewData(list));
   Struts2Utils.renderJson(gridServerHandler.getLoadResponseText());
 }
コード例 #2
0
  /** 保存用户信息 */
  public String save() throws ServiceStartupException {
    HttpServletRequest request = Struts2Utils.getRequest();
    String msg = "";
    String usemd5 =
        PropertiesUtil.getInstance().getProperty("system.password.save.encry"); // 数据库保存密码是否需要md5加密
    String newpw = entity.getVcPassword();
    if (usemd5 != null && usemd5.equalsIgnoreCase("MD5")) {
      newpw = Utils.getMD5String(entity.getVcPassword());
    }

    try {
      entity.setVcPassword(newpw);
      baseUserInfoManager.save(entity);
      request.setAttribute(VarConstants.SUCC_CODE, MsgConstants.SUCC_CODE_00101);
      msg = "添加用户信息[登录名:" + entity.getVcLoginName() + "]成功!";
      return SUCCESS;
    } catch (Exception e) {
      logger.error(e.getMessage());
      request.setAttribute(VarConstants.ERROR_CODE, MsgConstants.ERROR_CODE_00004);
      msg = "添加用户信息[登录名:" + entity.getVcLoginName() + "]失败!";
      return ERROR;
    } finally {
      commonManagerImpl.log(request, msg);
    }
  }
コード例 #3
0
  /** 页面视图数据 */
  private List formatViewData(List<TbBaseUserInfo> list) {
    List maplist = new ArrayList();
    Map map;
    TbBaseUserInfo bean;
    if (list != null && list.size() > 0) {
      for (int i = 0; i < list.size(); i++) {
        bean = list.get(i);
        VBaseUserInfo view = baseUserInfoManager.converBeanToView(bean);
        map = new LinkedHashMap();
        map.put("id", view.getId());
        map.put("vcLoginName", CommonUtils.killNull(view.getVcLoginName()));
        map.put("vcUserName", CommonUtils.killNull(view.getVcUserName()));
        map.put("vcMobel", CommonUtils.killNull(view.getVcMobel()));
        map.put("vcEmail", CommonUtils.killNull(view.getVcEmail()));
        map.put("vcTelephone", CommonUtils.killNull(view.getVcTelephone()));
        map.put("roleName", CommonUtils.killNull(view.getRoleName()));
        map.put("deptName", CommonUtils.killNull(view.getDeptName()));

        map.put("tiUserType", CommonUtils.killNull(view.getTiUserType()));
        map.put("vcPassword", CommonUtils.killNull(view.getVcPassword()));
        maplist.add(map);
      }
    }
    return maplist;
  }
コード例 #4
0
  /**
   * 分页查询数据
   *
   * @throws ServiceStartupException
   */
  public void setPaginationdataList() throws ServiceStartupException {
    HttpServletRequest request = Struts2Utils.getRequest();
    List<PropertyFilter> filters = HibernateWebUtils.buildPropertyFilters(request);

    // 如果选择按角色查询条件,则设置角色的过滤
    String vcRoleNo = request.getParameter("vcRoleNo2");
    if (vcRoleNo != null && !vcRoleNo.equals("")) {
      String vcUserNos = baseUserInfoManager.getUserIdByRoleId(vcRoleNo);
      String[] vun = vcUserNos.split(",");
      filters.add(new PropertyFilter("id", vun, MatchType.IN));
    }
    if (page.getOrderBy() == null) {
      page.setOrderBy("id");
    }
    page = baseUserInfoManager.search(page, filters);
    List dataList = page.getVresult();
    request.setAttribute("dataList", dataList);
  }
コード例 #5
0
 /** 打开权限树 */
 public String openPermis() throws ServiceStartupException {
   HttpServletRequest request = Struts2Utils.getRequest();
   String newrole_id = request.getParameter("role_id");
   List listdata = baseRoleManager.getAll();
   TbBaseUserInfo userInfo = baseUserInfoManager.get(id);
   List rolesIdList = null;
   if (Common.judgeString(newrole_id)) {
     rolesIdList = new ArrayList();
     rolesIdList.add(newrole_id);
   } else {
     // 根据用户标识获取角色标识集合
     rolesIdList = baseUserInfoManager.getRoles(userInfo.getId());
   }
   request.setAttribute("rolesIdList", rolesIdList);
   request.setAttribute("listdata", listdata);
   request.setAttribute("userId", id);
   request.setAttribute("vcUserNo", userInfo.getId());
   request.setAttribute("userName", entity == null ? "" : entity.getVcUserName());
   return ACTION_FORWORD_USERPERMIS_LIST;
 }
コード例 #6
0
 /** 支持使用Jquery.validate Ajax检验用户名是否重复. */
 public String checkUnique() {
   HttpServletRequest request = Struts2Utils.getRequest();
   String loginName = request.getParameter("entity.vcLoginName");
   String oldLoginName = request.getParameter("oldLoginName");
   if (baseUserInfoManager.isPropertyUnique("vcLoginName", loginName, oldLoginName)) {
     Struts2Utils.renderText("true");
   } else {
     Struts2Utils.renderText("false");
   }
   return null;
 }
コード例 #7
0
 /** 方法需修改测试 */
 public String doassociate() throws ServiceStartupException {
   HttpServletRequest request = Struts2Utils.getRequest();
   String userIds = keys;
   String roleNo = request.getParameter("roleNo");
   Long rolesId = roleId;
   boolean bo = baseUserInfoManager.inserMutilUserRoles(userIds, roleNo, request);
   if (bo) {
     addActionMessage(MsgConstants.SUCC_CODE_00028);
     return SUCCESS;
   } else {
     addActionMessage(MsgConstants.ERROR_CODE_00009);
     return ERROR;
   }
 }
コード例 #8
0
 /** 删除用户 */
 public void deleteUsers() throws Exception {
   HttpServletRequest request = ServletActionContext.getRequest();
   String ids = request.getParameter("ids");
   String[] sids = ids.split(",");
   String msg = "";
   try { // 删除成功
     baseUserInfoManager.deleteByKeys(sids);
     msg = "删除用户成功!";
     commonManagerImpl.log(request, "删除用户[主键:" + ids + "]成功!");
   } catch (Exception e) { // 删除失败
     msg = "删除用户成功\\!";
     commonManagerImpl.log(request, "删除用户[主键:" + ids + "]失败!");
   }
   Struts2Utils.renderText(msg);
 }
コード例 #9
0
 /** 保存用户信息 */
 public String update() throws ServiceStartupException {
   HttpServletRequest request = Struts2Utils.getRequest();
   String msg = "";
   try {
     baseUserInfoManager.save(entity);
     msg = " 编辑用户信息[登录名:" + entity.getVcLoginName() + "]成功!";
     request.setAttribute(VarConstants.SUCC_CODE, MsgConstants.SUCC_CODE_00102);
     return SUCCESS;
   } catch (Exception e) {
     request.setAttribute(VarConstants.ERROR_CODE, MsgConstants.ERROR_CODE_00004);
     msg = "编辑用户信息[登录名:" + entity.getVcLoginName() + "]失败!";
     return ERROR;
   } finally {
     commonManagerImpl.log(request, msg);
   }
 }
コード例 #10
0
 /** 核查旧密码合法性 */
 public String checkPwd() throws ServiceStartupException {
   HttpServletRequest request = Struts2Utils.getRequest();
   String oldPwd = request.getParameter("oldPwd");
   LoginListener loginListener =
       (LoginListener)
           ServletActionContext.getRequest()
               .getSession()
               .getAttribute(VarConstants.LOGIN_LISTENER_KEY);
   String userid = loginListener.getSessionContainer().getUserInfo().getId();
   TbBaseUserInfo userInfo = baseUserInfoManager.get(userid);
   if (Utils.getMD5String(oldPwd).equals(userInfo.getVcPassword())) {
     Struts2Utils.renderText("true");
   } else {
     Struts2Utils.renderText("false");
   }
   return null;
 }
コード例 #11
0
 /** 更新密码 */
 public String updatePwd() throws ServiceStartupException {
   HttpServletRequest request = Struts2Utils.getRequest();
   String oldPwd = request.getParameter("oldPwd");
   String newPwd = request.getParameter("newPwd");
   String msg = "";
   if (baseUserInfoManager.updatePwd(oldPwd, newPwd, request)) {
     request.setAttribute(VarConstants.SUCC_CODE, MsgConstants.SUCC_CODE_00106);
     msg = "更新用户密码[新密码:" + newPwd + "]成功!";
     commonManagerImpl.log(request, msg);
     return SUCCESS;
   } else {
     request.setAttribute(VarConstants.ERROR_CODE, MsgConstants.ERROR_CODE_00008);
     request.setAttribute(VarConstants.URL, "/welcome.jsp.do?1=1");
     msg = "更新用户密码[新密码:" + newPwd + "]失败!";
     commonManagerImpl.log(request, msg);
     return ERROR;
   }
 }
コード例 #12
0
 /** 删除用户 */
 public String delete() throws ServiceStartupException {
   HttpServletRequest request = Struts2Utils.getRequest();
   String[] sids = keys.split(",");
   String msg = null;
   try { // 删除成功
     baseUserInfoManager.deleteByKeys(sids);
     request.setAttribute(VarConstants.SUCC_CODE, MsgConstants.SUCC_CODE_00008);
     request.setAttribute(VarConstants.URL, "/user_list.do?1=1");
     msg = "删除用户信息[用户主键:" + keys + "]成功!";
     commonManagerImpl.log(request, msg);
     return SUCCESS;
   } catch (Exception e) { // 删除失败
     request.setAttribute(VarConstants.ERROR_CODE, MsgConstants.ERROR_CODE_00005);
     msg = "删除用户信息[用户主键:" + keys + "]失败!";
     commonManagerImpl.log(request, msg);
     return ERROR;
   }
 }
コード例 #13
0
 /** 重置密码 */
 public String resetPwd() throws ServiceStartupException {
   HttpServletRequest request = Struts2Utils.getRequest();
   String sids = Common.FormatString(keys, "0");
   boolean updateBoolean = baseUserInfoManager.updatePwdReset(sids, request);
   String msg = "";
   if (updateBoolean) {
     request.setAttribute(VarConstants.SUCC_CODE, MsgConstants.SUCC_CODE_00003);
     request.setAttribute(VarConstants.URL, "/user_list.do?1=1");
     msg = "重置用户密码[用户主键:" + keys + "]成功!";
     commonManagerImpl.log(request, msg);
     return SUCCESS;
   } else {
     request.setAttribute(VarConstants.ERROR_CODE, MsgConstants.ERROR_CODE_00007);
     request.setAttribute(VarConstants.URL, "/user_list.do?1=1");
     msg = "重置用户密码[用户主键:" + keys + "]失败!";
     commonManagerImpl.log(request, msg);
     return ERROR;
   }
 }
コード例 #14
0
  /** 插入用户权限 */
  public String insertPermis() throws ServiceStartupException {

    HttpServletRequest request = Struts2Utils.getRequest();
    String vcUserNo = request.getParameter("vcUserNo");
    String vcRoleNo = request.getParameter("vcRoleNo");
    String msg = "";
    boolean bo = baseUserInfoManager.inserUserRoles(vcUserNo, vcRoleNo, request);
    if (bo) {
      request.setAttribute(VarConstants.SUCC_CODE, MsgConstants.SUCC_CODE_00104);
      msg = "插入角色权限[权限关联字段:" + "vcUserNo:" + vcUserNo + " vcRoleNo:" + vcRoleNo + "]成功!";
      commonManagerImpl.log(request, msg);
      return SUCCESS;
    } else {
      request.setAttribute(VarConstants.ERROR_CODE, MsgConstants.ERROR_CODE_00009);
      request.setAttribute(VarConstants.URL, "/user_list.do?1=1");
      msg = "插入角色权限[权限关联字段:" + "vcUserNo:" + vcUserNo + " vcRoleNo:" + vcRoleNo + "]失败!";
      commonManagerImpl.log(request, msg);
      return ERROR;
    }
  }
コード例 #15
0
 public String edit() throws Exception {
   entity = baseUserInfoManager.get(id);
   return EDIT;
 }
コード例 #16
0
 /**
  * 获取编辑用户对象
  *
  * @return
  */
 public String openEditInfo() {
   TbBaseUserInfo beanView = baseUserInfoManager.get(id);
   ServletActionContext.getRequest().setAttribute("beanView", beanView);
   return ACTION_FROWORD_USER_EDIT;
 }