package org.springblade.manager.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.AllArgsConstructor;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.tool.node.ForestNodeMerger;
import org.springblade.manager.entity.WbsTreePrivate;

import org.springblade.manager.mapper.WbsTreePrivateMapper;
import org.springblade.manager.service.IWbsTreePrivateService;
import org.springblade.manager.vo.WbsTreePrivateVO;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
@AllArgsConstructor
public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMapper, WbsTreePrivate> implements IWbsTreePrivateService {
    @Override
    public List<WbsTreePrivateVO> tree(String wbsId, String projectId) {
        return ForestNodeMerger.merge(baseMapper.tree(wbsId, projectId));
    }


    public List<WbsTreePrivate> findAllNodeList(String wbsTreeIds, String projectId) {
        String[] ids = wbsTreeIds.split(",");
        List<Long> idList = new ArrayList<>();
        List<WbsTreePrivate> list = new ArrayList<>();
        for (String id : ids) {
            idList.add(Long.valueOf(id));
            WbsTreePrivate wbsTreePrivate = baseMapper.selectByCondition(id, projectId);
            list.add(wbsTreePrivate);
        }
        return list;
    }

}
