示例#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
  public List<SysApplication> getAccessAppList(long parentId, SysUser user) {
    long parentAppId = parentId;
    SysApplication parentApp = findById(parentId);
    if (parentApp != null) {
      parentAppId = parentApp.getNode().getId();
    }

    logger.debug("parent node:" + parentAppId);

    SysApplicationQuery query = new SysApplicationQuery();
    query.parentId(parentAppId);
    query.setLocked(0);
    List<Long> nodeIds = new java.util.ArrayList<Long>();
    nodeIds.add(-1L);

    List<SysApplication> apps = sysApplicationMapper.getSysApplicationByUserId(user.getId());
    if (apps != null && !apps.isEmpty()) {
      for (SysApplication app : apps) {
        nodeIds.add(app.getNodeId());
      }
    }
    query.nodeIds(nodeIds);

    return this.list(query);
  }
示例#3
0
  /**
   * 根据节点编号查找对象
   *
   * @param nodeId
   * @return
   */
  public SysApplication findByNodeId(long nodeId) {
    SysApplicationQuery query = new SysApplicationQuery();
    query.nodeId(nodeId);

    List<SysApplication> list = this.list(query);
    if (list != null && !list.isEmpty()) {
      SysApplication sysApplication = list.get(0);
      SysTree node = sysTreeService.findById(sysApplication.getNodeId());
      sysApplication.setNode(node);
      return sysApplication;
    }

    return null;
  }
示例#4
0
  public List<SysApplication> getApplicationList(long parentId) {
    long parentAppId = parentId;
    SysApplication parentApp = findById(parentId);
    if (parentApp != null) {
      parentAppId = parentApp.getNode().getId();
    }

    logger.info("parent node:" + parentAppId);

    SysApplicationQuery query = new SysApplicationQuery();
    query.parentId(parentAppId);
    query.setLocked(0);

    List<SysApplication> apps = this.list(query);
    logger.debug("----------------apps size:" + apps.size());
    return apps;
  }
示例#5
0
  public PageResult getApplicationList(long parentId, int pageNo, int pageSize) {
    // 计算总数
    PageResult pager = new PageResult();
    SysApplicationQuery query = new SysApplicationQuery();
    query.parentId(Long.valueOf(parentId));
    int count = this.count(query);
    if (count == 0) { // 结果集为空
      pager.setPageSize(pageSize);
      return pager;
    }

    int start = pageSize * (pageNo - 1);
    List<SysApplication> list = this.getSysApplicationsByQueryCriteria(start, pageSize, query);
    pager.setResults(list);
    pager.setPageSize(pageSize);
    pager.setCurrentPageNo(pageNo);
    pager.setTotalRecordCount(count);

    return pager;
  }