package com.xjrsoft.module.student.service.impl;

import com.github.yulichang.base.MPJBaseServiceImpl;
import com.xjrsoft.common.utils.TreeUtil;
import com.xjrsoft.module.student.dto.CadreDeptTreeDto;
import com.xjrsoft.module.student.entity.CadreDept;
import com.xjrsoft.module.student.mapper.CadreDeptMapper;
import com.xjrsoft.module.student.service.ICadreDeptService;
import com.xjrsoft.module.student.vo.CadreDeptTreeVo;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @title: 干部部门
* @Author szs
* @Date: 2023-12-20
* @Version 1.0
*/
@Service
@AllArgsConstructor
public class CadreDeptServiceImpl extends MPJBaseServiceImpl<CadreDeptMapper, CadreDept> implements ICadreDeptService {
    private final CadreDeptMapper cadreDeptMapper;
    @Override
    public List<CadreDeptTreeVo> getCadreDeptTree() {
        CadreDeptTreeDto dto = new CadreDeptTreeDto();
        return getCadreDeptTree(dto);
    }

    @Override
    public List<CadreDeptTreeVo> getCadreDeptTree(CadreDeptTreeDto dto) {

        List<CadreDeptTreeVo> list = cadreDeptMapper.getCadreDeptTree(dto);

        List<CadreDeptTreeVo> treeVoList = TreeUtil.build(list);
        return treeVoList;
    }
}
