Search in sources :

Example 1 with DepartDTO

use of vip.mate.system.dto.DepartDTO in project matecloud by matevip.

the class SysDepartServiceImpl method addDeptIdList.

private void addDeptIdList(List<Long> deptIdList, DepartDTO department) {
    List<DepartDTO> children = department.getChildren();
    if (children != null) {
        for (DepartDTO d : children) {
            deptIdList.add(d.getId());
            addDeptIdList(deptIdList, d);
        }
    }
}
Also used : DepartDTO(vip.mate.system.dto.DepartDTO)

Example 2 with DepartDTO

use of vip.mate.system.dto.DepartDTO in project matecloud by matevip.

the class SysDepartServiceImpl method selectDeptIds.

@Override
public List<Long> selectDeptIds(Long deptId) {
    DepartDTO depart = this.getDepart(deptId);
    List<Long> departIdList = new ArrayList<>();
    if (depart != null) {
        departIdList.add(depart.getId());
        addDeptIdList(departIdList, depart);
    }
    return departIdList;
}
Also used : ArrayList(java.util.ArrayList) DepartDTO(vip.mate.system.dto.DepartDTO)

Example 3 with DepartDTO

use of vip.mate.system.dto.DepartDTO in project matecloud by matevip.

the class SysDepartServiceImpl method getDepart.

private DepartDTO getDepart(Long id) {
    List<SysDepart> departs = this.list(Wrappers.<SysDepart>query().lambda().select(SysDepart::getId, SysDepart::getName, SysDepart::getParentId, SysDepart::getSort, SysDepart::getCreateTime));
    List<DepartDTO> sysDeparts = departs.stream().map(sysDepart -> {
        DepartDTO departDTO = new DepartDTO();
        BeanUtils.copyProperties(sysDepart, departDTO);
        return departDTO;
    }).collect(Collectors.toList());
    Map<Long, DepartDTO> map = sysDeparts.stream().collect(Collectors.toMap(SysDepart::getId, department -> department));
    for (DepartDTO dept : map.values()) {
        DepartDTO parent = map.get(dept.getParentId());
        if (parent != null) {
            List<DepartDTO> children = parent.getChildren() == null ? new ArrayList<>() : parent.getChildren();
            children.add(dept);
            parent.setChildren(children);
        }
    }
    return map.get(id);
}
Also used : ServiceImpl(com.baomidou.mybatisplus.extension.service.impl.ServiceImpl) Wrappers(com.baomidou.mybatisplus.core.toolkit.Wrappers) SysDepart(vip.mate.system.entity.SysDepart) SysDepartMapper(vip.mate.system.mapper.SysDepartMapper) SysDepartVO(vip.mate.system.vo.SysDepartVO) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) StrUtil(cn.hutool.core.util.StrUtil) ISysDepartService(vip.mate.system.service.ISysDepartService) List(java.util.List) Service(org.springframework.stereotype.Service) Map(java.util.Map) DepartDTO(vip.mate.system.dto.DepartDTO) ForestNodeMerger(vip.mate.core.web.tree.ForestNodeMerger) SysDepartPOI(vip.mate.system.poi.SysDepartPOI) BeanUtils(org.springframework.beans.BeanUtils) SysDepart(vip.mate.system.entity.SysDepart) DepartDTO(vip.mate.system.dto.DepartDTO)

Aggregations

DepartDTO (vip.mate.system.dto.DepartDTO)3 ArrayList (java.util.ArrayList)2 StrUtil (cn.hutool.core.util.StrUtil)1 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)1 Wrappers (com.baomidou.mybatisplus.core.toolkit.Wrappers)1 ServiceImpl (com.baomidou.mybatisplus.extension.service.impl.ServiceImpl)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 BeanUtils (org.springframework.beans.BeanUtils)1 Service (org.springframework.stereotype.Service)1 ForestNodeMerger (vip.mate.core.web.tree.ForestNodeMerger)1 SysDepart (vip.mate.system.entity.SysDepart)1 SysDepartMapper (vip.mate.system.mapper.SysDepartMapper)1 SysDepartPOI (vip.mate.system.poi.SysDepartPOI)1 ISysDepartService (vip.mate.system.service.ISysDepartService)1 SysDepartVO (vip.mate.system.vo.SysDepartVO)1