示例#1
0
  public String execute() throws Exception {
    PrintWriter out = response.getWriter();
    response.setCharacterEncoding("UTF-8");
    response.setContentType("application/json;charset=UTF-8");
    List list = sysRightsService.findSysRightsListByParentId(sysRightsId); // 查找
    try {
      if (list != null) {
        Iterator it = list.iterator();
        while (it.hasNext()) {
          SysRights sysRights = (SysRights) it.next();
          sysRightsService.deleteSysRightsByRightId(sysRights.getSysRightsId()); // 获得编号,执行批量删除
        }
        // 删除权限完成后,还要删除权限和角色的对应关系
        roleRightService.deleteBySysRightsId(sysRightsId); // 根据权限编号,进行删除,维护数据的完整性
      } else { // 该编号,不是编号
        sysRightsService.deleteSysRightsByRightId(sysRightsId); // 直接进行删除
        roleRightService.deleteBySysRightsId(sysRightsId);
      }

      out.write("[{\"success\":\"true\"}]");

    } catch (Exception e) {

      e.printStackTrace();
      out.write("[[{\"failure\":\"true\"}]");
    }
    out.flush();
    out.close();
    return null;
  }
示例#2
0
  public String execute() throws Exception {
    response.setCharacterEncoding("UTF-8");
    int count = sysRightsService.findAllCount();
    sysRightsList = sysRightsService.finsSysRightsByPage(page, rows);
    try {
      JSONObject json = new JSONObject();
      JSONArray jsonItems = new JSONArray();
      List list = sysRightsService.findSysRightsListByPaentId(0); // 父板块为0的子版快号
      Iterator it = list.iterator();
      while (it.hasNext()) {
        SysRights sysRights = (SysRights) it.next();
        Map map = new HashMap();
        map.put("sysRightsId", sysRights.getSysRightsId());
        map.put("sysRightsName", sysRights.getSysRightsName());
        map.put("className", sysRights.getClassName());
        map.put("type", sysRights.getType());
        map.put("status", sysRights.getStatus());
        List sonList =
            sysRightsService.findSysRightsListByPaentId(sysRights.getSysRightsId()); // 获得编号
        Iterator it2 = sonList.iterator();

        JSONObject sonJson = new JSONObject();
        JSONArray sonJsonItem = new JSONArray();
        while (it2.hasNext()) {
          SysRights sysRights2 = (SysRights) it2.next();
          Map map2 = new HashMap();
          map2.put("sysRightsId", sysRights2.getSysRightsId());
          map2.put("sysRightsName", sysRights2.getSysRightsName());
          map2.put("className", sysRights2.getClassName());
          map2.put("type", sysRights2.getType());
          map2.put("status", sysRights2.getStatus());
          sonJsonItem.add(map);
        }

        map.put("children", sonJsonItem);
        jsonItems.add(map);
      }
      json.put("total", count);
      json.put("rows", jsonItems);
      PrintWriter out = response.getWriter();
      out.write(json.toString());

      out.flush();
      out.close();

    } catch (Exception e) {

      e.printStackTrace();
    }
    return null;
  }