示例#1
0
  /**
   * 向前移动排序
   *
   * @param bean
   */
  private void sortByPrevious(long parentId, SysApplication bean) {
    // 查找前一个对象

    SysApplicationQuery query = new SysApplicationQuery();
    query.parentId(Long.valueOf(parentId));
    query.setSortGreaterThan(bean.getSort());
    query.setOrderBy(" E.SORT asc ");

    List<SysApplication> list = this.list(query);
    if (list != null && list.size() > 0) { // 有记录
      SysApplication temp = (SysApplication) list.get(0);
      int sort = bean.getSort();
      bean.setSort(temp.getSort() + 1);
      this.update(bean); // 更新bean
      SysTree node = sysTreeService.findById(bean.getNodeId());
      node.setSort(bean.getSort());
      sysTreeService.update(node);

      temp.setSort(sort - 1);
      this.update(temp); // 更新temp
      node = sysTreeService.findById(temp.getNodeId());
      node.setSort(temp.getSort());
      sysTreeService.update(node);
    }
  }
示例#2
0
 /**
  * 显示角色权限映射页面
  *
  * @param mapping
  * @param actionForm
  * @param request
  * @param response
  * @return
  * @throws Exception
  */
 public ActionForward showPrivilege(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   long deptId = ParamUtil.getLongParameter(request, "deptId", 0);
   long roleId = ParamUtil.getLongParameter(request, "roleId", 0);
   SysDeptRole deptRole = sysDeptRoleService.find(deptId, roleId);
   if (deptRole == null) { // 如果没有找到则创建一个
     deptRole = new SysDeptRole();
     deptRole.setDept(sysDepartmentService.findById(deptId));
     deptRole.setRole(sysRoleService.findById(roleId));
     sysDeptRoleService.create(deptRole);
   }
   request.setAttribute("role", deptRole);
   SysTree parent = sysTreeService.getSysTreeByCode(Constants.TREE_APP);
   List list = new ArrayList();
   sysTreeService.getSysTree(list, (int) parent.getId(), 0);
   request.setAttribute("list", list);
   return mapping.findForward("show_privilege");
 }
示例#3
0
  public JSONArray getUserMenu(long parent, String actorId) {
    JSONArray array = new JSONArray();
    SysUser user = authorizeService.login(actorId);
    if (user != null) {
      List<SysTree> treeList = null;
      SysApplication app = this.findById(parent);
      SysTreeQuery query = new SysTreeQuery();
      query.treeId(app.getNode().getTreeId());
      query.treeIdLike(app.getNode().getTreeId() + "%");
      if (!user.isSystemAdmin()) {
        List<String> actorIds = new java.util.ArrayList<String>();
        List<Object> rows = entityService.getList("getAgents", actorId);
        if (rows != null && !rows.isEmpty()) {
          for (Object object : rows) {
            if (object instanceof Agent) {
              Agent agent = (Agent) object;
              if (!agent.isValid()) {
                continue;
              }
              switch (agent.getAgentType()) {
                case 0: // 全局代理
                  actorIds.add(agent.getAssignFrom());
                  break;
                default:
                  break;
              }
            }
          }
        }
        if (!actorIds.isEmpty()) {
          actorIds.add(actorId);
          query.setActorIds(actorIds);
        } else {
          query.setActorId(actorId);
        }
        treeList = sysTreeMapper.getTreeListByUsers(query);
      } else {
        treeList = sysTreeMapper.getTreeList(query);
      }

      List<TreeModel> treeModels = new java.util.ArrayList<TreeModel>();
      for (SysTree tree : treeList) {
        if (StringUtils.isNotEmpty(tree.getUrl())) {
          if (StringUtils.startsWith(tree.getUrl(), "/")) {
            if (StringUtils.isNotEmpty(SystemConfig.getServiceUrl())) {
              String link = SystemConfig.getServiceUrl() + tree.getUrl();
              tree.setUrl(link);
            } else {
              String link = ApplicationContext.getContextPath() + tree.getUrl();
              tree.setUrl(link);
            }
          }
        }
        treeModels.add(tree);
      }
      TreeHelper treeHelper = new TreeHelper();
      array = treeHelper.getTreeJSONArray(treeModels);
      // logger.debug(array.toString('\n'));
    }
    return array;
  }