Search in sources :

Example 1 with SysDepart

use of vip.mate.system.entity.SysDepart in project matecloud by matevip.

the class SysDepartServiceImpl method export.

@Override
public List<SysDepartPOI> export() {
    LambdaQueryWrapper<SysDepart> queryWrapper = new LambdaQueryWrapper<>();
    queryWrapper.eq(SysDepart::getIsDeleted, 0);
    List<SysDepart> sysDeparts = this.baseMapper.selectList(queryWrapper);
    return sysDeparts.stream().map(sysDepart -> {
        SysDepartPOI sysDepartPOI = new SysDepartPOI();
        BeanUtils.copyProperties(sysDepart, sysDepartPOI);
        return sysDepartPOI;
    }).collect(Collectors.toList());
}
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) SysDepartPOI(vip.mate.system.poi.SysDepartPOI) SysDepart(vip.mate.system.entity.SysDepart) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 2 with SysDepart

use of vip.mate.system.entity.SysDepart 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)

Example 3 with SysDepart

use of vip.mate.system.entity.SysDepart in project matecloud by matevip.

the class SysDepartServiceImpl method searchList.

@Override
public List<SysDepartVO> searchList(Map<String, Object> search) {
    String keyword = String.valueOf(search.get("keyword"));
    String startDate = String.valueOf(search.get("startDate"));
    String endDate = String.valueOf(search.get("endDate"));
    LambdaQueryWrapper<SysDepart> lambdaQueryWrapper = new LambdaQueryWrapper<>();
    if (StrUtil.isNotBlank(startDate) && !startDate.equals(NULL)) {
        lambdaQueryWrapper.between(SysDepart::getCreateTime, startDate, endDate);
    }
    if (StrUtil.isNotBlank(keyword) && !keyword.equals(NULL)) {
        lambdaQueryWrapper.and(i -> i.or().like(SysDepart::getName, keyword).or().like(SysDepart::getId, keyword));
    }
    List<SysDepart> sysDeparts = this.baseMapper.selectList(lambdaQueryWrapper);
    List<SysDepartVO> sysDepartVOS = sysDeparts.stream().map(sysDepart -> {
        SysDepartVO sysDepartVO = new SysDepartVO();
        BeanUtils.copyProperties(sysDepart, sysDepartVO);
        return sysDepartVO;
    }).collect(Collectors.toList());
    return ForestNodeMerger.merge(sysDepartVOS);
}
Also used : SysDepartVO(vip.mate.system.vo.SysDepartVO) 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) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Aggregations

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