示例#1
0
  /**
   * 修改的时候验证是否存在 栏位名(输出栏位名的数量,已经排除了本身)
   *
   * @param column
   * @param response
   */
  @RequestMapping(value = "/updateQueryCountByObj")
  public void updateQueryCountByObj(Column column, HttpServletResponse response) {
    int infoMsg = 0;
    try {
      List<Column> list =
          columnService.queryColumnByObj(
              new Column(null, column.getColumnName(), null, null, null)); // 传入了一个 columnName查询出来
      for (Column columnNew : list) { // 遍历一下。栏位id不等于 要修改的栏位id的时候(名字相等,id不相等),则infoMSg + 1
        if (!columnNew.getColumnId().equals(column.getColumnId())) {
          infoMsg = infoMsg + 1;
        }
      }
      /*if(list.size()>0){//加入只有一条的话,则为本身。
      	infoMsg = list.size();
      }*/
    } catch (Exception e) {
      log.error("updateQueryCountByObj error通过对象查询数量出错");
    }

    response.setContentType("text/html;charset=utf-8");
    PrintWriter pw = null;
    try {
      pw = response.getWriter();
      pw.write(infoMsg + ""); // 一定要转化为字符串
      pw.flush();
    } catch (IOException e) {
      log.error("pw.write(jsonData.toString())  error");
    } finally {
      if (pw != null) {
        pw.close();
      }
    }
  }
示例#2
0
  /**
   * 修改栏位信息的实现
   *
   * @param column
   * @param response
   */
  @RequestMapping(
      value = "/updateColumnAction",
      method = {RequestMethod.POST})
  public void updateColumnAction(Column column, HttpServletResponse response) {
    String infoMsg = "";
    boolean b = true;
    try {
      b = columnService.updateColumn(column);
      if (b) {
        infoMsg = "updateSuc";
        getColumnMap().remove(column.getColumnId()); // 对应的总容器中也修改
        getColumnMap().put(column.getColumnId(), column);
      }
    } catch (Exception e) {
      infoMsg = "updateError";
      log.error("updateColumn error 修改栏位出错");
    }

    response.setContentType("text/html;charset=utf-8");
    PrintWriter pw = null;
    try {
      pw = response.getWriter();
      pw.write(infoMsg);
      pw.flush();
    } catch (IOException e) {
      log.error("pw.write(jsonData.toString())  error");
    } finally {
      if (pw != null) {
        pw.close();
      }
    }
  }
示例#3
0
  /**
   * 通过对象查询数量(用于验证是否存在)
   *
   * @param column
   * @param response
   */
  @RequestMapping(value = "/queryCountByObj")
  public void queryCountByObj(Column column, HttpServletResponse response) {

    int infoMsg = 0;
    try {
      infoMsg = columnService.queryCountByObj(column);
      /*if(list.size()>0){//加入只有一条的话,则为本身。
      	infoMsg = list.size();
      }*/
    } catch (Exception e) {
      log.error("queryCountByObj error通过对象查询数量出错");
    }

    response.setContentType("text/html;charset=utf-8");
    PrintWriter pw = null;
    try {
      pw = response.getWriter();
      pw.write(infoMsg + "");
      pw.flush();
    } catch (IOException e) {
      log.error("pw.write(jsonData.toString())  error");
    } finally {
      if (pw != null) {
        pw.close();
      }
    }
  }
示例#4
0
  /**
   * 添加栏位的实现
   *
   * @param response 输出添加成功与否的信息
   * @return
   */
  @RequestMapping(
      value = "/insertColumnAction",
      method = {RequestMethod.POST, RequestMethod.GET})
  public void insertColumnAction(HttpServletResponse response, Column column) {
    String uuid = UUID.randomUUID().toString().replace("-", "");
    column.setColumnId(uuid);
    String infoMsg = "";
    try {
      boolean b = columnService.insertColumn(column);
      if (b) {
        infoMsg = "addSuc";
        getColumnMap().put(column.getColumnId(), column); // 对应的总容器中也添加相应的栏位信息
      } else {
        infoMsg = "addError";
      }
    } catch (Exception e) {
      infoMsg = "addError";
      log.error("insertColumn  error 添加栏位出错");
    }

    response.setContentType("text/html;charset=utf-8");
    PrintWriter pw = null;
    try {
      pw = response.getWriter();
      pw.write(infoMsg);
      pw.flush();
    } catch (IOException e) {
      log.error("pw.write(jsonData.toString())  error");
    } finally {
      if (pw != null) {
        pw.close();
      }
    }
    // return "redirect:/column/queryAllColumn.do";
  }
示例#5
0
  /**
   * 查询所有栏位的实现方法(带分页)。模糊查询也是调用此方法
   *
   * @return
   */
  @RequestMapping(value = "/queryAllColumnAction")
  public void queryAllColumnAction(
      Column column, Resource resource, HttpServletRequest request, HttpServletResponse response) {

    // 分页查询
    List<Column> list = new ArrayList<Column>();
    if (column != null && column.getSort() != null && column.getSort().trim() != "") {
      column.setSort(column.getSort().toLowerCase()); // 排序字段全部转化为小写。避免Linux系统 排序字段报错
    }
    column.setResource(resource);

    try {
      list = columnService.queryAllColumn(column);
    } catch (Exception e) {
      log.error("queryAllColumn error分页查询栏位出错");
    }

    // 查询总数
    int count = 0;
    try {
      count = columnService.queryColumnCount(column);
    } catch (Exception e) {
      log.error("queryColumnCount error 查询菜单栏位总数出错");
    }

    Map<String, Object> userEasyUIMap = new HashMap<String, Object>();
    userEasyUIMap.put("rows", list); // easyUI需要用的rows
    userEasyUIMap.put("total", count); // easyUI需要用的总数

    response.setContentType("text/html;charset=utf-8");
    PrintWriter pw = null;
    try {
      pw = response.getWriter();
      // pw.print(jsonData);
      // pw.write(JSONArray.fromObject(userMap).toString()); //输出的全部是字符串
      pw.write(JSONObject.fromObject(userEasyUIMap).toString()); // 输入的是json key Object的字符串
      pw.flush();
    } catch (IOException e) {
      // e.printStackTrace();
      log.error("输出json出错");
    } finally {
      if (pw != null) {
        pw.close();
      }
    }
  }
示例#6
0
  /**
   * 批量删除
   *
   * @param request 获取页面参数
   * @return
   */
  @RequestMapping(
      value = "/deleteRessById",
      method = {RequestMethod.POST, RequestMethod.GET})
  public void deleteRessById(HttpServletRequest request, HttpServletResponse response) {

    String resids = request.getParameter("resids");
    String infoMsg = ""; // 记录用户操作是否得成功的信息
    try {
      String[] idsArray = resids.split(",");
      for (int i = 0; i < idsArray.length; i++) {
        int privlgCount =
            privilegeService.queryCountByObj(
                new Privilege(null, idsArray[i], null, true, null, null));
        if (privlgCount > 0) { // 一旦查询出来,有用户在用该权限,则返回
          infoMsg = "isUsed";
          break;
        }

        int columnCount =
            columnService.queryCountByObj(new Column(null, null, null, idsArray[i], null));
        if (columnCount > 0) {
          infoMsg = "isUsed";
          break;
        }
      }
      if (!"isUsed".equals(infoMsg)) { // 没有被使用
        boolean b = resourceService.deleteRessById(resids);
        if (b) {
          infoMsg = "delSuc";
          for (int i = 0; i < idsArray.length; i++) {
            getResMap().remove(idsArray[i]);
          }
        } else {
          infoMsg = "delError";
        }
      }

    } catch (Exception e) {
      infoMsg = "delError";
      log.error("deleteUsersById error 批量删除出错");
    }

    response.setContentType("text/html;charset=utf-8");
    PrintWriter pw = null;
    try {
      pw = response.getWriter();
      pw.write(infoMsg);
      pw.flush();
    } catch (IOException e) {
      log.error("pw.write(jsonData.toString())  error");
    } finally {
      if (pw != null) {
        pw.close();
      }
    }

    // return "redirect:/resource/queryAllResource.do";
  }
示例#7
0
  /**
   * 批量删除栏位
   *
   * @param request
   * @param response
   */
  @RequestMapping(value = "/deleteColumnsById")
  public void deleteColumnsById(HttpServletRequest request, HttpServletResponse response) {
    String ids = request.getParameter("ids");

    String infoMsg = "";
    boolean b;
    try {
      b = columnService.deleteColumnsById(ids);
      if (b) {
        infoMsg = "delSuc"; // 删除成功
        String[] idsArray = ids.split(",");
        for (int i = 0; i < idsArray.length; i++) {
          getColumnMap().remove(idsArray[i]);
        }
      } else {
        infoMsg = "delError";
      }
    } catch (Exception e) {
      infoMsg = "delError";
      log.error("deleteColumnsById error通过id批量栏位删除出错");
    }

    response.setContentType("text/html;charset=utf-8");
    PrintWriter pw = null;
    try {
      pw = response.getWriter();
      pw.write(infoMsg);
      pw.flush();
    } catch (IOException e) {
      log.error("pw.write(jsonData.toString())  error");
    } finally {
      if (pw != null) {
        pw.close();
      }
    }
  }