Search in sources :

Example 1 with DepartIdModel

use of org.jeecg.modules.system.model.DepartIdModel in project jeecg-boot by jeecgboot.

the class FindsDepartsChildrenUtil method findChildren.

/**
 * queryTreeList的子方法 ====2=====
 * 该方法是找到并封装顶级父类的节点到TreeList集合
 */
private static List<SysDepartTreeModel> findChildren(List<SysDepartTreeModel> recordList, List<DepartIdModel> departIdList) {
    List<SysDepartTreeModel> treeList = new ArrayList<>();
    for (int i = 0; i < recordList.size(); i++) {
        SysDepartTreeModel branch = recordList.get(i);
        if (oConvertUtils.isEmpty(branch.getParentId())) {
            treeList.add(branch);
            DepartIdModel departIdModel = new DepartIdModel().convert(branch);
            departIdList.add(departIdModel);
        }
    }
    getGrandChildren(treeList, recordList, departIdList);
    // idList = departIdList;
    return treeList;
}
Also used : ArrayList(java.util.ArrayList) SysDepartTreeModel(org.jeecg.modules.system.model.SysDepartTreeModel) DepartIdModel(org.jeecg.modules.system.model.DepartIdModel)

Example 2 with DepartIdModel

use of org.jeecg.modules.system.model.DepartIdModel in project jeecg-boot by jeecgboot.

the class FindsDepartsChildrenUtil method wrapTreeDataToTreeList.

// 部门树信息-树结构
// private static List<SysDepartTreeModel> sysDepartTreeList = new ArrayList<SysDepartTreeModel>();
// 部门树id-树结构
// private static List<DepartIdModel> idList = new ArrayList<>();
/**
 * queryTreeList的子方法 ====1=====
 * 该方法是s将SysDepart类型的list集合转换成SysDepartTreeModel类型的集合
 */
public static List<SysDepartTreeModel> wrapTreeDataToTreeList(List<SysDepart> recordList) {
    // 在该方法每请求一次,都要对全局list集合进行一次清理
    // idList.clear();
    List<DepartIdModel> idList = new ArrayList<DepartIdModel>();
    List<SysDepartTreeModel> records = new ArrayList<>();
    for (int i = 0; i < recordList.size(); i++) {
        SysDepart depart = recordList.get(i);
        records.add(new SysDepartTreeModel(depart));
    }
    List<SysDepartTreeModel> tree = findChildren(records, idList);
    setEmptyChildrenAsNull(tree);
    return tree;
}
Also used : ArrayList(java.util.ArrayList) SysDepart(org.jeecg.modules.system.entity.SysDepart) SysDepartTreeModel(org.jeecg.modules.system.model.SysDepartTreeModel) DepartIdModel(org.jeecg.modules.system.model.DepartIdModel)

Example 3 with DepartIdModel

use of org.jeecg.modules.system.model.DepartIdModel in project jeecg-boot by jeecgboot.

the class SysUserDepartServiceImpl method queryDepartIdsOfUser.

/**
 * 根据用户id查询部门信息
 */
@Override
public List<DepartIdModel> queryDepartIdsOfUser(String userId) {
    LambdaQueryWrapper<SysUserDepart> queryUDep = new LambdaQueryWrapper<SysUserDepart>();
    LambdaQueryWrapper<SysDepart> queryDep = new LambdaQueryWrapper<SysDepart>();
    try {
        queryUDep.eq(SysUserDepart::getUserId, userId);
        List<String> depIdList = new ArrayList<>();
        List<DepartIdModel> depIdModelList = new ArrayList<>();
        List<SysUserDepart> userDepList = this.list(queryUDep);
        if (userDepList != null && userDepList.size() > 0) {
            for (SysUserDepart userDepart : userDepList) {
                depIdList.add(userDepart.getDepId());
            }
            queryDep.in(SysDepart::getId, depIdList);
            List<SysDepart> depList = sysDepartService.list(queryDep);
            if (depList != null || depList.size() > 0) {
                for (SysDepart depart : depList) {
                    depIdModelList.add(new DepartIdModel().convertByUserDepart(depart));
                }
            }
            return depIdModelList;
        }
    } catch (Exception e) {
        e.fillInStackTrace();
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) SysUserDepart(org.jeecg.modules.system.entity.SysUserDepart) SysDepart(org.jeecg.modules.system.entity.SysDepart) DepartIdModel(org.jeecg.modules.system.model.DepartIdModel)

Example 4 with DepartIdModel

use of org.jeecg.modules.system.model.DepartIdModel in project kms by mahonelau.

the class SysUserDepartServiceImpl method queryDepartIdsOfUser.

/**
 * 根据用户id查询部门信息
 */
@Override
public List<DepartIdModel> queryDepartIdsOfUser(String userId) {
    LambdaQueryWrapper<SysUserDepart> queryUDep = new LambdaQueryWrapper<SysUserDepart>();
    LambdaQueryWrapper<SysDepart> queryDep = new LambdaQueryWrapper<SysDepart>();
    try {
        queryUDep.eq(SysUserDepart::getUserId, userId);
        List<String> depIdList = new ArrayList<>();
        List<DepartIdModel> depIdModelList = new ArrayList<>();
        List<SysUserDepart> userDepList = this.list(queryUDep);
        if (userDepList != null && userDepList.size() > 0) {
            for (SysUserDepart userDepart : userDepList) {
                depIdList.add(userDepart.getDepId());
            }
            queryDep.in(SysDepart::getId, depIdList);
            List<SysDepart> depList = sysDepartService.list(queryDep);
            if (depList != null || depList.size() > 0) {
                for (SysDepart depart : depList) {
                    depIdModelList.add(new DepartIdModel().convertByUserDepart(depart));
                }
            }
            return depIdModelList;
        }
    } catch (Exception e) {
        e.fillInStackTrace();
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) SysUserDepart(org.jeecg.modules.system.entity.SysUserDepart) SysDepart(org.jeecg.modules.system.entity.SysDepart) DepartIdModel(org.jeecg.modules.system.model.DepartIdModel)

Example 5 with DepartIdModel

use of org.jeecg.modules.system.model.DepartIdModel in project kms by mahonelau.

the class FindsDepartsChildrenUtil method findChildren.

/**
 * queryTreeList的子方法 ====2=====
 * 该方法是找到并封装顶级父类的节点到TreeList集合
 */
private static List<SysDepartTreeModel> findChildren(List<SysDepartTreeModel> recordList, List<DepartIdModel> departIdList) {
    List<SysDepartTreeModel> treeList = new ArrayList<>();
    for (int i = 0; i < recordList.size(); i++) {
        SysDepartTreeModel branch = recordList.get(i);
        if (oConvertUtils.isEmpty(branch.getParentId())) {
            treeList.add(branch);
            DepartIdModel departIdModel = new DepartIdModel().convert(branch);
            departIdList.add(departIdModel);
        }
    }
    getGrandChildren(treeList, recordList, departIdList);
    // idList = departIdList;
    return treeList;
}
Also used : ArrayList(java.util.ArrayList) SysDepartTreeModel(org.jeecg.modules.system.model.SysDepartTreeModel) DepartIdModel(org.jeecg.modules.system.model.DepartIdModel)

Aggregations

DepartIdModel (org.jeecg.modules.system.model.DepartIdModel)15 ArrayList (java.util.ArrayList)12 SysDepartTreeModel (org.jeecg.modules.system.model.SysDepartTreeModel)12 SysDepart (org.jeecg.modules.system.entity.SysDepart)9 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)3 SysUserDepart (org.jeecg.modules.system.entity.SysUserDepart)3