package com.engine.organization.entity.searchtree;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @description:
 * @author:dxfeng
 * @createTime: 2022/05/26
 * @version: 1.0
 */
@Data
public class SearchTreeParams {
    /**
     * 数据类型
     * <p>
     * 0：集团
     * 1：分部
     * 2：部门
     * 3：岗位
     */
    private String type;
    private String id;
    private String isVirtual;
    // 树搜索条件
    private String keyword;
    private String virtualCompanyid;
    private String isLoadSubDepartment;

    // 人员筛选，添加分部、部门、岗位、人员搜索条件
    private String subcompanyid1;
    private String departmentid;
    private String jobId;
    private String resourceId;
    private boolean personnelScreening;

    public List<Integer> getSubcompanyid1() {
        if (StringUtils.isBlank(subcompanyid1)) {
            return new ArrayList<>();
        }
        return Arrays.stream(subcompanyid1.split(",")).map(Integer::parseInt).collect(Collectors.toList());
    }

    public List<Integer> getDepartmentid() {
        if (StringUtils.isBlank(departmentid)) {
            return new ArrayList<>();
        }
        return Arrays.stream(departmentid.split(",")).map(Integer::parseInt).collect(Collectors.toList());
    }

    public List<Long> getJobId() {
        if (StringUtils.isBlank(jobId)) {
            return new ArrayList<>();
        }
        return Arrays.stream(jobId.split(",")).map(Long::parseLong).collect(Collectors.toList());
    }

    public List<Long> getResourceId() {
        if (StringUtils.isBlank(resourceId)) {
            return new ArrayList<>();
        }
        return Arrays.stream(resourceId.split(",")).map(Long::parseLong).collect(Collectors.toList());
    }
}
