Search in sources :

Example 1 with DeptTree

use of com.github.liuweijw.business.commons.tree.DeptTree in project fw-cloud-framework by liuweijw.

the class DeptServiceImpl method getDeptTree.

private List<DeptTree> getDeptTree(List<Dept> list, int rootId) {
    List<DeptTree> treeList = new ArrayList<DeptTree>();
    for (Dept dept : list) {
        // 排除父节点和自己节点相同的数据
        if (dept.getPid().intValue() == dept.getDeptId().intValue())
            continue;
        DeptTree node = new DeptTree();
        node.setId(dept.getDeptId() + "");
        node.setPid(dept.getPid() + "");
        node.setName(dept.getDeptName());
        node.setPos(dept.getPos());
        treeList.add(node);
    }
    return TreeUtil.build(treeList, "0");
}
Also used : QDept(com.github.liuweijw.business.admin.domain.QDept) Dept(com.github.liuweijw.business.admin.domain.Dept) ArrayList(java.util.ArrayList) DeptTree(com.github.liuweijw.business.commons.tree.DeptTree)

Example 2 with DeptTree

use of com.github.liuweijw.business.commons.tree.DeptTree in project fw-cloud-framework by liuweijw.

the class DeptServiceImpl method getDeptTreeList.

@Override
@Cacheable(key = "'dept_tree_list'", unless = "#result eq null")
public List<DeptTree> getDeptTreeList() {
    QDept dept = QDept.dept;
    List<Dept> list = this.queryFactory.selectFrom(dept).where(dept.statu.eq(0)).fetch();
    if (null == list || list.size() == 0)
        return new ArrayList<DeptTree>();
    return getDeptTree(list, 0);
}
Also used : QDept(com.github.liuweijw.business.admin.domain.QDept) QDept(com.github.liuweijw.business.admin.domain.QDept) Dept(com.github.liuweijw.business.admin.domain.Dept) DeptTree(com.github.liuweijw.business.commons.tree.DeptTree) Cacheable(org.springframework.cache.annotation.Cacheable)

Aggregations

Dept (com.github.liuweijw.business.admin.domain.Dept)2 QDept (com.github.liuweijw.business.admin.domain.QDept)2 DeptTree (com.github.liuweijw.business.commons.tree.DeptTree)2 ArrayList (java.util.ArrayList)1 Cacheable (org.springframework.cache.annotation.Cacheable)1