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);
}
}
}
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;
}
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);
}
Aggregations