package com.engine.organization.transmethod;


import com.engine.organization.entity.DeleteParam;
import com.engine.organization.mapper.employee.EmployeeMapper;
import com.engine.organization.mapper.hrmresource.SystemDataMapper;
import com.engine.organization.util.db.MapperProxyFactory;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;

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

/**
 * @Author weaver_cl
 * @Description:
 * @Date 2022/10/26
 * @Version V1.0
 **/
public class ManagerDetachTransMethod {

    public static String getManagerName(String ecManager) {
        if (org.apache.commons.lang.StringUtils.isBlank(ecManager)) {
            return "";
        }
        List<Long> collect = Arrays.stream(ecManager.split(",")).map(Long::parseLong).collect(Collectors.toList());
        if (CollectionUtils.isEmpty(collect)) {
            return "";
        }
        List<String> employeeNameById = MapperProxyFactory.getProxy(EmployeeMapper.class).getEmployeeNameById(collect);
        return StringUtils.join(employeeNameById, ",");
    }


    public static String getRoleLevel(String ecRolelevel) {
        List<Map<String, Object>> maps = MapperProxyFactory.getProxy(SystemDataMapper.class).getBrowserDatas(DeleteParam.builder().ids(ecRolelevel).build().getIds());
        String names = maps.stream().map(item -> (String) item.get("name")).collect(Collectors.joining(","));
        return names;
    }
}
