Beispiel #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();
      }
    }
  }
Beispiel #2
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";
  }
Beispiel #3
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();
      }
    }
  }
Beispiel #4
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();
      }
    }
  }