package com.hz.pm.api.organization.service.impl;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hz.pm.api.organization.mapper.DingEmployeeInfoMapper;
import com.hz.pm.api.organization.model.entity.DingEmployeeInfo;
import com.hz.pm.api.organization.service.IDingEmployeeInfoService;
import org.springframework.stereotype.Service;

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

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Lierbao
 * @since 2023-02-11
 */
@Service
public class DingEmployeeInfoServiceImpl extends ServiceImpl<DingEmployeeInfoMapper, DingEmployeeInfo> implements IDingEmployeeInfoService {

    @Override
    public List<String> getEmployeesOrgCodeList(List<String> employeeCodeList) {
        if (CollUtil.isEmpty(employeeCodeList)) {
            return Collections.emptyList();
        }
        List<DingEmployeeInfo> dingEmployeeInfoList = this.list(Wrappers.lambdaQuery(DingEmployeeInfo.class).in(DingEmployeeInfo::getEmployeeCode, employeeCodeList));
        return dingEmployeeInfoList.stream().map(DingEmployeeInfo::getOrganizationCode).distinct().collect(Collectors.toList());
    }

    @Override
    public List<DingEmployeeInfo> getEmployeeList(List<String> employeeCodeList) {
        if (CollUtil.isEmpty(employeeCodeList)) {
            return Collections.emptyList();
        }
        return list(Wrappers.lambdaQuery(DingEmployeeInfo.class)
                .in(DingEmployeeInfo::getEmployeeCode, employeeCodeList));
    }
}
