package com.engine.organization.entity.hrmresource.bo;

import com.engine.organization.entity.hrmresource.po.ResourcePO;
import com.engine.organization.entity.searchtree.SearchTree;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author:dxfeng
 * @createTime: 2022/12/28
 * @version: 1.0
 */
public class ResourceBO {

    public static List<SearchTree> buildSetToSearchTree(Collection<ResourcePO> builderJobs) {
        return builderJobs.stream().map(item -> {
            SearchTree tree = new SearchTree();
            tree.setCanClick(true);
            tree.setCanceled(false);
            tree.setIcon("icon-coms-currency-Customer");
            tree.setId(item.getId().toString());
            tree.setIsParent(false);
            tree.setIsVirtual("0");
            tree.setName(item.getLastName());
            tree.setPid("0");
            tree.setSelected(false);
            tree.setType("4");
            tree.setParentComp(null == item.getJobId() ? "0" : item.getJobId().toString());
            tree.setOrderNum(null == item.getDspOrder() ? 0 : item.getDspOrder());
            return tree;
        }).collect(Collectors.toList());

    }
}
