Search in sources :

Example 1 with SysOrg

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;
}
Also used : ServiceImpl(com.baomidou.mybatisplus.extension.service.impl.ServiceImpl) Wrappers(com.baomidou.mybatisplus.core.toolkit.Wrappers) SecurityUserUtils(com.tansci.utils.SecurityUserUtils) SysOrgRole(com.tansci.domain.system.SysOrgRole) SysOrgService(com.tansci.service.system.SysOrgService) Autowired(org.springframework.beans.factory.annotation.Autowired) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) Collectors(java.util.stream.Collectors) SysOrgRoleService(com.tansci.service.system.SysOrgRoleService) ArrayList(java.util.ArrayList) SysOrgMapper(com.tansci.mapper.system.SysOrgMapper) Objects(java.util.Objects) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) Service(org.springframework.stereotype.Service) SysOrg(com.tansci.domain.system.SysOrg) Transactional(org.springframework.transaction.annotation.Transactional) SysOrg(com.tansci.domain.system.SysOrg) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Aggregations

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 SysOrg (com.tansci.domain.system.SysOrg)1 SysOrgRole (com.tansci.domain.system.SysOrgRole)1 SysOrgMapper (com.tansci.mapper.system.SysOrgMapper)1 SysOrgRoleService (com.tansci.service.system.SysOrgRoleService)1 SysOrgService (com.tansci.service.system.SysOrgService)1 SecurityUserUtils (com.tansci.utils.SecurityUserUtils)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects (java.util.Objects)1 Collectors (java.util.stream.Collectors)1 Slf4j (lombok.extern.slf4j.Slf4j)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Service (org.springframework.stereotype.Service)1 Transactional (org.springframework.transaction.annotation.Transactional)1