Exemplo n.º 1
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();
      }
    }
  }
Exemplo n.º 2
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";
  }