use of com.tansci.domain.system.SysOrg in project tansci by typ1805.
the class SysOrgServiceImpl method list.
@Override
public List<SysOrg> list(SysOrg sysOrg) {
LambdaQueryWrapper queryWrapper = null;
if (Objects.equals(0, SecurityUserUtils.getUser().getType())) {
queryWrapper = Wrappers.<SysOrg>lambdaQuery().eq(SysOrg::getDelFlag, 0).like(Objects.nonNull(sysOrg.getName()), SysOrg::getName, sysOrg.getName()).orderByDesc(SysOrg::getCreateTime);
} else {
queryWrapper = Wrappers.<SysOrg>lambdaQuery().eq(SysOrg::getDelFlag, 0).in(SysOrg::getId, SecurityUserUtils.getUser().getOrgIds()).like(Objects.nonNull(sysOrg.getName()), SysOrg::getName, sysOrg.getName()).orderByDesc(SysOrg::getCreateTime);
}
List<SysOrg> orgList = this.baseMapper.selectList(queryWrapper);
List<SysOrg> newOrgList = orgList.stream().filter(item -> item.getParentId() == 0).map(item -> {
item.setChildren(this.getChildrens(item, orgList));
return item;
}).sorted((item1, item2) -> {
return (item1.getSort() == null ? 0 : item1.getSort()) - (item2.getSort() == null ? 0 : item2.getSort());
}).collect(Collectors.toList());
return newOrgList.size() > 0 ? newOrgList : orgList;
}
Aggregations