Example #1
0
 /**
  * 查询子站点
  *
  * @return
  */
 public String authSon() {
   try {
     List<Site> list = null;
     // 提取子站点
     list = siteService.selectByParId(root);
     // 生成树
     StringBuilder stringBuilder = new StringBuilder();
     stringBuilder.append("[");
     if (list != null && list.size() > 0) {
       for (int i = 0; i < list.size(); i++) {
         if (site != null
             && site.getId() != null
             && site.getId().trim().length() > 0
             && site.getId().equals(list.get(i).getId())) {
           continue;
         }
         if (!"[".equals(stringBuilder.toString())) {
           stringBuilder.append(",");
         }
         stringBuilder.append("{ \"text\": \"<a  onclick=");
         if (onclick != null && onclick.trim().length() > 0) {
           stringBuilder.append(onclick);
         } else {
           stringBuilder.append("showDetail");
         }
         stringBuilder.append("('");
         stringBuilder.append(list.get(i).getId());
         stringBuilder.append(
             "','"
                 + list.get(i).getName().replaceAll(" ", "")
                 + "','"
                 + (site != null && site.getId() != null ? site.getId() : "")
                 + "')>");
         stringBuilder.append(list.get(i).getName());
         // 判断是否有权限
         if (role != null
             && role.getId().trim().length() > 0
             && roleSiteService.have(list.get(i).getId(), role.getId())) {
           stringBuilder.append(" ★");
         }
         stringBuilder.append("\", \"hasChildren\": ");
         if (siteService.hasChildren(list.get(i).getId())) {
           stringBuilder.append("true");
         } else {
           stringBuilder.append("false");
         }
         stringBuilder.append(",\"id\":\"");
         stringBuilder.append(list.get(i).getId());
         stringBuilder.append("\" }");
       }
     }
     stringBuilder.append("]");
     ResponseUtil.writeUTF(getHttpResponse(), stringBuilder.toString());
   } catch (Exception e) {
     e.printStackTrace();
   }
   return null;
 }
Example #2
0
 /**
  * 查询子站点
  *
  * @return
  */
 public String checkSon() {
   try {
     List<Site> list = null;
     // 提取子站点
     list = siteService.selectByParId(root);
     // 生成树
     StringBuilder stringBuilder = new StringBuilder();
     stringBuilder.append("[");
     if (list != null && list.size() > 0) {
       for (int i = 0; i < list.size(); i++) {
         if (site != null
             && site.getId() != null
             && site.getId().trim().length() > 0
             && site.getId().equals(list.get(i).getId())) {
           continue;
         }
         if (!"[".equals(stringBuilder.toString())) {
           stringBuilder.append(",");
         }
         stringBuilder.append("{ \"text\": \"<input onclick='siteCheck(this)' type=checkbox ");
         if (sites != null
             && sites.trim().length() > 0
             && sites.indexOf(list.get(i).getId() + ";") > -1) {
           stringBuilder.append("checked");
         }
         stringBuilder.append(
             " name=sites value=" + list.get(i).getId() + " show=" + list.get(i).getName() + ">");
         stringBuilder.append(list.get(i).getName());
         stringBuilder.append("\", \"hasChildren\": ");
         if (siteService.hasChildren(list.get(i).getId())) {
           stringBuilder.append("true");
         } else {
           stringBuilder.append("false");
         }
         stringBuilder.append(",\"id\":\"");
         stringBuilder.append(list.get(i).getId());
         stringBuilder.append("\" }");
       }
     }
     stringBuilder.append("]");
     ResponseUtil.writeUTF(getHttpResponse(), stringBuilder.toString());
   } catch (Exception e) {
     e.printStackTrace();
   }
   return null;
 }