package cn.iocoder.yudao.module.customer.api.info;

import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.customer.api.info.dto.CustomerInfoDTO;
import cn.iocoder.yudao.module.customer.dal.dataobject.info.CustomerInfoDO;
import cn.iocoder.yudao.module.customer.service.info.CustomerInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * 客户 API 实现类
 *
 * @author zhaopq
 */
@Service
public class CustomerInfoApiImpl implements CustomerInfoApi {

    @Resource
    private CustomerInfoService customerInfoService;

    @Override
    public List<CustomerInfoDTO> getCustomerInfoList(Collection<Long> ids) {
        if (CollUtil.isEmpty(ids)) {
            return Collections.emptyList();
        }
        List<CustomerInfoDO> customerInfoDOList = customerInfoService.getCustomerInfoList(ids);
        return BeanUtils.toBean(customerInfoDOList, CustomerInfoDTO.class);
    }

    @Override
    public CustomerInfoDTO getCustomerInfo(Long id) {
        CustomerInfoDO customerInfoDO = customerInfoService.getInfo(id);
        return BeanUtils.toBean(customerInfoDO, CustomerInfoDTO.class);
    }
}
