Пример #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;
 }
Пример #2
0
 /**
  * 单个站点授权页面
  *
  * @return
  */
 public String authPage() {
   if (site != null
       && site.getId().trim().length() > 0
       && role != null
       && role.getId().trim().length() > 0) {
     site = siteService.findById(site.getId());
     // 判断是否有站点管理权限
     roleSite = roleSiteService.findBySiteRole(site.getId(), role.getId());
     channelTreeContent = new StringBuffer();
     channelService.createTree(
         channelTreeContent,
         (isAdminLogin() ? "admin" : getLoginRoleIdsSql()),
         site.getId(),
         role.getId(),
         "par",
         null,
         null,
         "checkbox");
   }
   return "authPage";
 }
Пример #3
0
 /**
  * 单个站点授权页面处理
  *
  * @return
  */
 public String authPageDo() {
   if (site != null
       && site.getId().trim().length() > 0
       && role != null
       && role.getId().trim().length() > 0) {
     // 先清除原来的权限
     roleSiteService.del(site.getId(), role.getId());
     roleChannelService.delByRole(role.getId());
     // 添加新的权限
     if ("1".equals(manageSiteChecked)) {
       roleSiteService.save(
           site.getId(),
           role.getId(),
           (roleSite != null && roleSite.getSiteadmin() != null) ? roleSite.getSiteadmin() : "");
       if (channelTree != null && channelTree.length > 0) {
         for (int i = 0; i < channelTree.length; i++) {
           roleChannelService.save(role.getId(), channelTree[i]);
         }
       }
     }
   }
   write(
       "<script>alert('操作成功');location.href='site_authPage.do?site.id="
           + site.getId()
           + "&role.id="
           + role.getId()
           + "';</script>",
       "GBK");
   return null;
 }
Пример #4
0
 /**
  * 多项选择站点
  *
  * @return
  */
 public String siteCheck() {
   if (isAdminLogin()) {
     // 查询一级站点
     siteList = siteService.selectByParId("");
   } else {
     // 非管理员只查询有权限的站点
     siteList = siteService.selectByRoles(getLoginRoleIdsSql());
   }
   if (siteList != null && siteList.size() > 0) {
     if (role != null) {
       for (int i = 0; i < siteList.size(); i++) {
         if (roleSiteService.have(siteList.get(i).getId(), role.getId())) {
           siteList.get(i).setHaveSiteRole("1");
         }
       }
     }
   }
   return "siteCheck";
 }
Пример #5
0
 /**
  * 授权页面
  *
  * @return
  */
 public String auth() {
   // 如果是管理员登录则提取一级站点
   if (isAdminLogin()) {
     siteList = siteService.selectByParId("");
   } else {
     // 普通用户只提取有自己有权限的站点
     siteList = siteService.selectByRoles(getLoginRoleIdsSql());
   }
   // 设置、
   if (siteList != null && siteList.size() > 0) {
     if (role != null) {
       for (int i = 0; i < siteList.size(); i++) {
         if (roleSiteService.have(siteList.get(i).getId(), role.getId())) {
           siteList.get(i).setHaveSiteRole(" <font color='blue'>★</font>");
         }
       }
     }
   }
   return "auth";
 }